Last active
March 20, 2023 08:57
-
-
Save Gavin0x0/de050b00fca3c5ec6a0f2aae99a72ff5 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
// ***SOLVED*** | |
var globalStream; | |
navigator.mediaDevices.getUserMedia({ | |
audio: true, | |
video: true | |
}) | |
.then(function(stream) { | |
globalStream = stream; | |
}) | |
.catch(function(err) { | |
console.log(err) | |
}); | |
function stopStream() { | |
if (!globalStream) return; | |
globalStream.getAudioTracks().forEach(function(track) { | |
track.stop(); | |
}); | |
globalStream.getVideoTracks().forEach(function(track) { | |
track.stop(); | |
}); | |
globalStream = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment