Screenshare

Overview

Starts a screenshare from the Local Participant. Peers can share their whole screen, a specific window, or a browser tab. Four events are associated with screensharing, and they are all emitted from the Conference class: localShareCreated, localShareClosed, screenShareCreated, and screenShareClosed

Using the listeners

To start screensharing and stop screensharing, you can pass a config as second argument.

conf.on('localShareCreated', () => {
    // handle state/ui updates here
})

conf.on('localShareClosed', () => {
    // handle state/ui updates here
})

conf.on('screenShareCreated', (p: Peer) => {
    // handle state/ui updates here
    
    // access the video screen and push it
    document.getElementById('screenshareView').append(p.video)
})

conf.on('screenShareClosed', (peerId) => {
    document.getElementById(peerId).remove()
})

Starting and stopping a screenshare

To start screensharing and stop screensharing, there's two simple functions to use.

// starting screenshare
try {
    await conf.startScreenshare()
} catch (error) {
    console.log("screenshare error", error)
}

// stopping screenshare
try {
    await conf.stopScreenshare()
} catch (error) {
    console.log("screenshare error", error)
}