I'm trying to switch source - screen to webcam (LIVE). I've started from function addStream()
and after executing it I'm getting this error:
DOMException: Failed to execute 'webkitGetUserMedia' on 'Navigator': At least one of audio and video must be requested(…) Object {audio: false, video: false}
Here is the code:
function switchToWebcam() {
connection.sdpConstraints.mandatory = {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
};
connection.addStream({
video: true,
audio: true
});
}
Maybe there are other ways to switch source. Just can't find an example. Thanks.
Here is how to add audio+video stream in a screensharing session:
connection.session.audio = true;
connection.session.video = true;
connection.addStream({
audio: true, // because session.audio==true, now it works
video: true, // because session.video==true, now it works
oneway: true
});
You can try this audio+screen demo on Canary. This demo has "Add Video" button as well.