Error:
Uncaught (in promise) DOMException: Could not start video source
What I tried:
I checked that is my chrome is allowed to access camera and it was allowed.
I tried to updated my camera drive but no updates were available.
This error comes mostly but sometimes my site doesn't give this error.
How to resolve this issue?
It is a problem of my laptop and it is still saying that my code has an error pls give any solutions
Code:
getDevices: async function(){
let $this = this;
navigator.mediaDevices
.enumerateDevices()
.then(function(devices) {
devices.forEach(function(device) {
if(device.kind == "audioinput"){
$this.microphones.push(device);
}
else if(device.kind == "audiooutput"){
$this.speakers.push(device);
}
else if(device.kind == "videoinput"){
$this.cameras.push(device);
}
});
});
let videoStream = await navigator.mediaDevices.getUserMedia({video: true,audio: false});
let audioStream = await navigator.mediaDevices.getUserMedia({video: false,audio: true});
const combinedStream = new MediaStream(
[
...videoStream.getVideoTracks(),
...audioStream.getAudioTracks()
]
);
document.getElementById("myVideo").srcObject=combinedStream;
document.getElementById("myVideo").muted = true;
},
setCamera: async function(){
let videoStream = await navigator.mediaDevices.getUserMedia({video:{deviceId:this.selectedCamera},audio: false});
let audioStream = await navigator.mediaDevices.getUserMedia({video: false,audio: true});
const combinedStream = new MediaStream(
[
...videoStream.getVideoTracks(),
...audioStream.getAudioTracks()
]
);
document.getElementById("myVideo").srcObject=combinedStream;
document.getElementById("myVideo").muted = true;
}, //It says that The error is on this line and the error is Uncaught (in promise) DOMException: Could not start video source.
-Thanks For All Your Solutions