GUACAMOLE-237: Merge changes migrating to navigator.mediaDevices.getUserMedia rather than deprecated navigator.getUserMedia.

This commit is contained in:
Michael Jumper
2018-01-03 10:32:05 -08:00

View File

@@ -181,16 +181,20 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
*/ */
var context = Guacamole.AudioContextFactory.getAudioContext(); var context = Guacamole.AudioContextFactory.getAudioContext();
/** // Some browsers do not implement navigator.mediaDevices - this
* A function which directly invokes the browser's implementation of // shims in this functionality to ensure code compatibility.
* navigator.getUserMedia() with all provided parameters. if (!navigator.mediaDevices)
* navigator.mediaDevices = {};
* @type Function
*/ // Browsers that either do not implement navigator.mediaDevices
var getUserMedia = (navigator.getUserMedia // at all or do not implement it completely need the getUserMedia
|| navigator.webkitGetUserMedia // method defined. This shims in this function by detecting
|| navigator.mozGetUserMedia // one of the supported legacy methods.
|| navigator.msGetUserMedia).bind(navigator); if (!navigator.mediaDevices.getUserMedia)
navigator.mediaDevices.getUserMedia = (navigator.getUserMedia
|| navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia
|| navigator.msGetUserMedia).bind(navigator);
/** /**
* Guacamole.ArrayBufferWriter wrapped around the audio output stream * Guacamole.ArrayBufferWriter wrapped around the audio output stream
@@ -419,7 +423,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
var beginAudioCapture = function beginAudioCapture() { var beginAudioCapture = function beginAudioCapture() {
// Attempt to retrieve an audio input stream from the browser // Attempt to retrieve an audio input stream from the browser
getUserMedia({ 'audio' : true }, function streamReceived(stream) { navigator.mediaDevices.getUserMedia({ 'audio' : true }, function streamReceived(stream) {
// Create processing node which receives appropriately-sized audio buffers // Create processing node which receives appropriately-sized audio buffers
processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels); processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);