File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
src/main/java/gwt/material/design/addins/client/camera Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -242,14 +242,23 @@ protected void nativePlay(Element video) {
242242
243243 Navigator .mediaDevices .getUserMedia (constraints ).then (streamObj -> {
244244 mediaStream = (MediaStream ) streamObj ;
245- if (URL .createObjectURL (mediaStream ) != null ) {
246- $ (video ).attr ("src" , URL .createObjectURL (mediaStream ));
247- } else if (WebkitURL .createObjectURL (mediaStream ) != null ) {
248- $ (video ).attr ("src" , WebkitURL .createObjectURL (mediaStream ));
249- }
250- if (video instanceof VideoElement ) {
251- ((VideoElement ) video ).play ();
245+
246+ if (mediaStream != null ) {
247+ try {
248+ video .setPropertyObject ("srcObject" , mediaStream );
249+ } catch (Exception e ) {
250+ if (URL .createObjectURL (mediaStream ) != null ) {
251+ $ (video ).attr ("src" , URL .createObjectURL (mediaStream ));
252+ } else if (WebkitURL .createObjectURL (mediaStream ) != null ) {
253+ $ (video ).attr ("src" , WebkitURL .createObjectURL (mediaStream ));
254+ }
255+ } finally {
256+ if (video instanceof VideoElement ) {
257+ ((VideoElement ) video ).play ();
258+ }
259+ }
252260 }
261+
253262 onCameraCaptureLoad ();
254263 return null ;
255264 }).catchException (error -> {
You can’t perform that action at this time.
0 commit comments