Skip to content

Instantly share code, notes, and snippets.

@soulfly
Created December 19, 2017 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulfly/99d4eb819ffdc23e61b9f789059f2215 to your computer and use it in GitHub Desktop.
Save soulfly/99d4eb819ffdc23e61b9f789059f2215 to your computer and use it in GitHub Desktop.
switchVideoinput: function(mediaDeviceId, callbacks){
// stop & close previous local peer
this.videoRoomPlugin.hangup(true);
// request new stream
var constraints = {
audio: true,
video: {deviceId: {exact: mediaDeviceId}}
};
//
var self = this;
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
setTimeout(function(){
self.createOffer(true, !self.isOnlyAudio, stream, {
success: function() {
if(typeof callbacks.success === 'function'){
Utils.safeCallbackCall(callbacks.success);
}
},
error: function(error){
if(typeof callbacks.error === 'function'){
Utils.safeCallbackCall(callbacks.error, error);
}
}
});
}, 1000);
})
.catch(function(error) {
if(typeof callbacks.error === 'function'){
Utils.safeCallbackCall(callbacks.error, error);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment