Skip to content

Instantly share code, notes, and snippets.

@sorie
Created July 2, 2021 07:47
Show Gist options
  • Save sorie/42258c344b70efdb536573cebe5e051b to your computer and use it in GitHub Desktop.
Save sorie/42258c344b70efdb536573cebe5e051b to your computer and use it in GitHub Desktop.
getUserMedia error test
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