Skip to content

Commit

Permalink
use mediaDevices
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasmcm committed Sep 29, 2022
1 parent 8308441 commit 6b8bbd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions javascripts/lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ var QuietLab = (function() {
onReceive: onReceive,
onCreate: function() {
if (source === undefined) {
var gUM = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);
gUM.call(navigator, gUMConstraints(), onGUM, onGUMFail);
navigator.mediaDevices.getUserMedia(gUMConstraints()).then(onGUM).catch(onGUMFail)
} else {
source.connect(analyser);
drawFFT();
Expand Down
19 changes: 9 additions & 10 deletions javascripts/quiet.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,16 @@ var Quiet = (function() {
function createAudioInput() {
audioInput = 0; // prevent others from trying to create
window.setTimeout(function() {
gUM.call(navigator, gUMConstraints(),
function(e) {
audioInput = audioCtx.createMediaStreamSource(e);
navigator.mediaDevices.getUserMedia(gUMConstraints()).then(function(e) {
audioInput = audioCtx.createMediaStreamSource(e);

// stash a very permanent reference so this isn't collected
window.quiet_receiver_anti_gc = audioInput;
// stash a very permanent reference so this isn't collected
window.quiet_receiver_anti_gc = audioInput;

audioInputReady();
}, function(reason) {
audioInputFailed(reason.name);
});
audioInputReady();
}).catch(function(reason) {
audioInputFailed(reason.name);
})
}, 0);
};

Expand Down Expand Up @@ -739,7 +738,7 @@ var Quiet = (function() {
// quiet does not create an audio input when it starts
// getting microphone access requires a permission dialog so only ask for it if we need it
if (gUM === undefined) {
gUM = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);
gUM = navigator.mediaDevices.getUserMedia;
}

if (gUM === undefined) {
Expand Down

0 comments on commit 6b8bbd6

Please sign in to comment.