Created
July 2, 2021 07:47
-
-
Save sorie/42258c344b70efdb536573cebe5e051b to your computer and use it in GitHub Desktop.
getUserMedia error test
This file contains hidden or 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
let constraints = {video: true}; | |
(async () => { | |
try{ | |
await navigator.mediaDevices.getUserMedia(constraints).then(function (param, streams) { | |
throw error | |
if (getLocalStream) { | |
/*mediaDevices체크 */ | |
let videoTracks = streams.getVideoTracks(); | |
let audioTracks = streams.getAudioTracks(); | |
console.log('dev test selected camera : ' + videoTracks[0].label); | |
console.log('dev test selected audio : ' + audioTracks[0].label); | |
} | |
}.bind(this, param)) | |
// .catch(function (param, error) { | |
// }.bind(this, param)); | |
} catch (error) { | |
//기본 카메라를 읽지 못하면 그 다음 카메라를 체크 하는 로직 | |
await navigator.mediaDevices.getUserMedia(constraints); | |
let devices = await navigator.mediaDevices.enumerateDevices(); | |
console.log(devices) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment