Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
themeRDark
constraints = {audio:true, video:{frameRate:{ideal:30}}

Seamless switching between web camera stream and screen share stream during publication

During webinars it is often necessary to switch between streams captured from conductors web camera and screen share while streams are published. Ideally, such switching should be seamless, and conductors michrophone soundtrack must be continued. In latest WebSDK versions this feature is implemented for Chrome and Firefox browsers, let's look at the sample in Media Devices application.

Image Added

Image Added

1. While streaming from chosen microphone and camera, when switch 'Screen share' is set to 'on' switchToScreen functioun will be invoked

stream.switchToScreen code

Code Block
languagejs
themeRDark
function switchToScreen() {
    if (publishStream) {
        $('#switchBtn').prop('disabled', true);
        $('#videoInput').prop('disabled', true);
        publishStream.switchToScreen($('#mediaSource').val()).catch(function () {
            $("#screenShareToggle").removeAttr("checked");
            $('#switchBtn').prop('disabled', false);
            $('#videoInput').prop('disabled', false);
        });
    }
}

Media stream source (screen) should be passed to this function.

2. Then user should choose whole screen or certain program window to share with Chrome extension or with Firefox dialog box:

Image Added

3. Screen share stream is published to server

Image Added

Sound translation source is not changed.

4. To revert back web camera streaming switch ToCam function is invoked

stream.switchToCam code

Code Block
languagejs
themeRDark
function switchToCam() {
    if (publishStream) {
        publishStream.switchToCam();
        $('#switchBtn').prop('disabled', false);
        $('#videoInput').prop('disabled', false);
    }
}

Known limitations

1. Stream switching works in Chrome and Firefox browsers only.

2. It is impossible to switch web camera while screen share stream is published.

3. Extension is necessary to capture screen in Chrome browser.

Known issues

1. Microphone swithing does not work in Safari browser.

...