Reputation: 62
My website is using a video stream based on peerjs/WebRTC.
This worked perfectly a few days ago. Yesterday I switched to SSL because you can't access media devices without it. Since then the video isn't working in Chrome. Everytime I open my website I get the following error message:
DOMException: Could not start video source
This is my source code for the video stream:
let myPeer = new Peer(undefined, {
host: "192.168.178.28",
port: "3000",
path: "/peerjs",
key: "peerjs",
});
let myVideo = document.createElement("video");
myVideo.muted = true; // mute own video
navigator.mediaDevices
.getUserMedia({ // get video and audio from user
video: {
width: { max: 320},
height: { max: 240},
},
audio: true,
})
.then((stream) => {
addVideoStream(myVideo, stream); // add video to peer
Socket.emit("giveAllUsers");
Socket.on("allUsers", (data) => {
for (let x of data) {
if (x != myId) {
connectToNewUser(x, stream); //connect to new users
}
}
});
myPeer.on("call", (call) => {
call.answer(stream);
const video = document.createElement("video");
call.on("stream", (userVideoStream) => {//new stream
addVideoStream(video, userVideoStream);
});
call.on("close", () => {//remove users video when call is closed
video.remove();
});
peers[call.peer] = call;
console.log(peers);
});
})
.catch(error => {
console.error('error: ', error);
});
The same error occurs in Edge.
However, it still works in Firefox AND in the mobile version of Chrome!
Does anyone have an idea what's happening? Why is SSL causing this in Chrome and Edge but not in Firefox and the mobile version of Chrome?
Upvotes: 0
Views: 3871
Reputation: 62
Got it.
For some reason Chrome (and ONLY Chrome) tried to use the camera of my connected vr headset which didn't work. If some of you have this problem in the future: make sure that Chrome tries to access the right cam.
Upvotes: 0