| name | screen-sharing |
| description | Start and stop screen sharing during calls. Web clients can initiate screen sharing. Use when implementing screen share, listening for screen share events, or checking presenter status. Triggers on "screen sharing", "screen share", "share screen", "startScreenSharing". |
| inclusion | manual |
CometChat Calls SDK v5 — Screen Sharing
Overview
The Web Calls SDK can initiate and receive screen shares. When a user starts screen sharing, the browser's native screen picker dialog appears. The call layout automatically adjusts to display shared content.
Key Imports
import { CometChatCalls } from '@cometchat/calls-sdk-javascript';
Implementation
Start / Stop Screen Sharing
CometChatCalls.startScreenSharing();
CometChatCalls.stopScreenSharing();
Listen for Screen Share Events (Local)
CometChatCalls.addEventListener('onScreenShareStarted', () => {
});
CometChatCalls.addEventListener('onScreenShareStopped', () => {
});
Listen for Participant Screen Share Events
CometChatCalls.addEventListener('onParticipantStartedScreenShare', (participant) => {
console.log(`${participant.name} started screen sharing`);
});
CometChatCalls.addEventListener('onParticipantStoppedScreenShare', (participant) => {
console.log(`${participant.name} stopped screen sharing`);
});
Configure Screen Share Button Visibility
const sessionSettings: SessionSettings = {
hideScreenSharingButton: false,
};
Handle Button Click Event
CometChatCalls.addEventListener('onScreenShareButtonClicked', () => {
});
Gotchas
- Screen sharing requires HTTPS (or localhost) — browsers block
getDisplayMedia() on HTTP
- The browser shows its own screen picker dialog — the SDK cannot bypass this
- Only one user can screen share at a time in a session
- If the user cancels the browser picker, no event fires
- The user can also stop sharing via the browser's native "Stop sharing" button —
onScreenShareStopped fires in both cases
- Screen sharing may pause the local video (depending on browser/device) — the SDK handles this automatically
- Android/iOS mobile clients can receive screen shares from web but cannot initiate them