Skip to content

Instantly share code, notes, and snippets.

@Gavin0x0
Last active March 20, 2023 08:57
Show Gist options
  • Save Gavin0x0/de050b00fca3c5ec6a0f2aae99a72ff5 to your computer and use it in GitHub Desktop.
Save Gavin0x0/de050b00fca3c5ec6a0f2aae99a72ff5 to your computer and use it in GitHub Desktop.
获取所有设备【已解决】
// ***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