Provides the mechanism for controlling the published screen-sharing stream.
In order to access the screen publisher, you will need to start screen
sharing first. By default, screen sharing doesn’t share audio.
In order to share audio from a browser tab, the user who shares
the screen must check the option “Share audio” in Chrome when the
screen/tab dialog selector shows up.
You can access the ScreenPublisher
object via the
screen
property of the Room
object, as follows:
await room.startScreensharing('screenSharingContainer');
const { screen } = room;
screen.on('stopped', () => {
console.log('The screen sharing has stopped');
});
screen.on('started', () => {
console.log('The screen sharing has started');
});
screen.on('audioLevelUpdated', (audioLevel) => {
console.log('Audio level: ', audioLevel);
});
Methods
Name | Description |
---|---|
(void)
disableAudio
()
|
Disables the audio track. |
(void)
disableVideo
()
|
Disables the video track. |
(void)
enableAudio
()
|
Enables the audio track. |
(void)
enableVideo
()
|
Enables the video track. |
(boolean)
isAudioEnabled
()
|
Returns true when the audio track is enabled.
Otherwise it returns false .
|
(boolean)
isVideoEnabled
()
|
Returns true when the video track is enabled.
Otherwise it returns false .
|
(void)
setDisabledImageURI
(disabledImageURI)
|
Accepts an image URI (string) and updates the publisher
backgroundImageURI property. Currently supported image formats include:
PNG , JPEG , or a non-animated GIF . You can also use the
data URI scheme and pass in base-64-encrypted PNG data or
SVG data. If the URL or image data is invalid, the property is ignored and a
default image is set. Returns void.
|
Events
Name | Description |
---|---|
audioLevelUpdated
|
Emits audioLevel (Number ). Dispatched periodically
by the screen publisher to indicate the audio level. This event is dispatched
up to 60 times per second, depending on the browser. The audioLevel
value is the audio level, from 0 to 1.0.
|
started
|
Dispatched when the screen publisher starts screen sharing. This event does not emit anything. |
stopped
|
Dispatched when the screen publisher stops screen sharing. This event does not emit anything. |