Created
December 19, 2017 11:48
-
-
Save soulfly/99d4eb819ffdc23e61b9f789059f2215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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