accelerator-screen-sharing-js icon indicating copy to clipboard operation
accelerator-screen-sharing-js copied to clipboard

Enable sharing tab audio along with screensharing

Open ytzvan opened this issue 4 years ago • 4 comments

Hello, I'm looking to achieve the native audio sharing option that is available inside chrome / edge. However I could not find a way to initialize this property using the TokBox sdk.

Currently if you pass a property to getDisplayMedia, you'll be able to see the option of share audio while screensharing in Chrome / Edge.

This is the native example: navigator.mediaDevices.getDisplayMedia({audio: true, video: true}) How can I achieve the above using the tokbox skd? Is there an option to pass properties while the screensharing is on ?

Thanks.

ytzvan avatar Aug 25 '20 14:08 ytzvan

Hi, we stumbled upon this issue when migrating to Tokbox SDK. We are trying to share a Chrome Tab with its audio, but Chrome's dialog never shows the checkbox to share the audio, even when we have the publishAudio set to true. We already tried videoSource "screen", "window" and "application".

Do you have any suggestions?

Thanks!

mauriciogior avatar Oct 02 '20 15:10 mauriciogior

Hello @mauriciogior in order to Chrome shows you the checkbox for enable audio, you need to call getDisplayMedia() first, and then pass the values as property when you cal thel start() method.

try {
      const stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: true });
      const audioSource= stream.getAudioTracks()[0];
      const videoSource = stream.getVideoTracks()[0];
      if (audioSource && videoSource  ) {
         const props = { audioSource, videoSource };
      }
    } catch (e) {
      console.log('Error getting Stream', e);
    }

then when you start the screensharing:

const openTokCore = new Core({});
openTokCore.start(props);

regards

ytzvan avatar Oct 02 '20 15:10 ytzvan

Hi @ytzvan, thanks for the detailed answer! I'm using OpenTok.js SDK (https://tokbox.com/developer/sdks/js/reference/), I can't find the Core object to instantiate it. Does it work with the default SDK as well or should I dig into the code of this repository?

Thanks.

mauriciogior avatar Oct 02 '20 22:10 mauriciogior

Hi @mauriciogior, our accelerators are built on top of the OpenTok.js SDK. You won't have access to them with just the SDK. However, all the functionality they provide is built using the SDK so anything the accelerators add is something you are capable of doing with the SDK alone.

michaeljolley avatar Oct 05 '20 14:10 michaeljolley