Screen Share

Screenshare involves sharing either the complete screen, a specific window or, a browser tab. For a peer to share their screen, their role must have screenshare enabled in the dashboard.

ScreenshareDashboard

To start a screenshare:

try { await hmsActions.setScreenShareEnabled(true); } catch (error) { // an error will be thrown if user didn't give access to share screen }

AudioOnly Screenshare

To start audio only screenshare, you can pass a boolean as second argument. it defaults to false

try { await hmsActions.setScreenShareEnabled(true, true); } catch (error) { // an error will be thrown if user didn't give access to share screen }

To stop the screenshare:

hmsActions.setScreenShareEnabled(false);

Useful Selectors

// to know if someone is screensharing const screenshareOn = hmsStore.getState(selectIsSomeoneScreenSharing); // to get the HMSPeer object of the peer screensharing, will select first if multiple screenshares const presenter = hmsStore.getState(selectPeerScreenSharing); // to get the HMSPeer object of all the peers screensharing const presenters = hmsStore.getState(selectPeersScreenSharing); // a boolean to know if the local peer is the one who is screensharing const amIScreenSharing = hmsStore.getState(selectIsLocalScreenShared); // to get the screenshare video track, this can be used to call attachVideo for rendering const screenshareVideoTrack = hmsStore.getState(selectScreenShareByPeerID(presenter.id)); // Get the peer who is sharing audio only screenshare const peer = hmsStore.getState(selectPeerSharingAudio); // Get the audio track of audio Only screenshare const audioTrack = hmsStore.getState(selectScreenShareAudioByPeerID(peer?.id));

Find more here.

Screenshare with audio:

We also give support of adding screenshare with audio in chromium based browsers. This only applies if checkbox at bottom left shown below is checked while sharing a browser tab.

ScreenshareAudio