0

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.

morozRed
  • 176
  • 4
  • 14

1 Answers1

0

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.

Muaz Khan
  • 7,138
  • 9
  • 41
  • 77
  • It works, thanks. Do I need to remove screen stream before creating this new? I'm just trying to make it work in "Scalable Screenshare Broadcast" example – morozRed Apr 22 '16 at 09:55
  • Scalable-broadcast demo doesn't supports multi-stream features. So you can not add new streams. You can either share screen or audio+screen or audio+video where single MediaStream is shared/relayed. – Muaz Khan Apr 22 '16 at 16:43