javascript - MediaStream Unhandled Promise Rejection: [object DOMError] (in Safari 11) -


i getting unhandled promise rejection in safari tech preview 11 in method below initialize webrtc. specifically, occurs when assign mediastream video element this: video.srcobject = event.stream; - stack trace shows line 1 threw exception. have not been able catch exception using try/catch.

the exception occurring in safari 11 (does not occur in chrome).

here method:

initwebrtc(p){     var self = this;     return new promise((resolve, reject) => {        self.state.connection = new rtcmulticonnection();       self.state.connection.socketmessageevent = 'webrtc-firebase';       self.state.connection.setcustomsockethandler(firebaseconnection);       self.state.connection.firebase = 'webrtc-firebase';        self.state.connection.enablefilesharing = true;        self.state.connection.session = {         audio: true,         video: true,         data: true       };       self.state.connection.sdpconstraints.mandatory = {         offertoreceiveaudio: true,         offertoreceivevideo: true       };       self.state.connection.onstream = function(event) {           console.log('event.mediaelement',event.mediaelement);           console.log('event.stream',event.stream);            var videocontainer = document.getelementbyid('videocontainer');           var video = event.mediaelement;           if (!window.safari){             var source = document.createelement("source");             source.srcobject = event.stream;             video.appendchild(source);           } else { // safari             try{               video.srcobject = event.stream; // line throws exception             }catch(e){ //unable catch exception               console.log('exception',e);             }           }           videocontainer.appendchild(video);            var playpromise = video.play();           if (playpromise !== undefined) { // not promise in browsers             playpromise.catch(function(error) {             });           }           settimeout(function() {             var playpromise = video.play();             if (playpromise !== undefined) {               playpromise.catch(function(error) {               });             }           }, 5000);       };       resolve();     });   } 

not sure if helps, here trace:

[error] unhandled promise rejection: [object domerror]     (anonymous function)     rejectpromise     onstream (index.js:5787) // video.srcobject = event.stream; line     (anonymous function) (rtcmulticonnection.js:4092)     getrmcmediaelement (rtcmulticonnection.js:1113)     ongettinglocalmedia (rtcmulticonnection.js:4064)     ongettinglocalmedia (rtcmulticonnection.js:4984)     streaming (rtcmulticonnection.js:3289)     (anonymous function) (rtcmulticonnection.js:3358)     promisereactionjob 

any appreciated. thanks!

safari 11 blocks autoplay video sound default (source).

i believe video element comes autoplay attribute. when set srcobject it, try play video -- , got blocked safari. that's why see error.

you can try remove autoplay video element, may able catch in playpromise.catch.


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

javascript - Replicate keyboard event with html button -