Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Zoom Video SDK Web
https://github.com/zoom/videosdk-web
Admin
Power custom video experiences with Zoom's core technology
Tokens:
295,431
Snippets:
2,037
Trust Score:
8.2
Update:
6 days ago
Context
Chat
Benchmark
74.12
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Check and start recording example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/recording.md JavaScript example showing how to check if recording can start and if the current status is not already 'Recording', then start cloud recording. ```javascript if (recording.canStartRecording() && recording.getCloudRecordingStatus() !== RecordingStatus.Recording) { await recording.startCloudRecording() } ``` -------------------------------- ### Check support and start real-time media streams Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/real-time-media-streams.md JavaScript example showing how to check support and permission, then start real-time media streams using the client. ```JavaScript const rtms = client.getRealTimeMediaStreamsClient() if (rtms.isSupportRealTimeMediaStreams() && rtms.canStartRealTimeMediaStreams()) { await rtms.startRealTimeMediaStreams() } ``` -------------------------------- ### Complete whiteboard integration example Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/whiteboard.md This example shows the full integration flow: initializing the client, joining a session, getting the whiteboard client, checking availability, setting up event listeners for whiteboard state changes, starting the whiteboard as presenter, and exporting before stopping. It includes error handling and a warning when whiteboard is not available. ```javascript const client = ZoomVideo.createClient(); let whiteboardClient; client.init("en-us", "Global"); // Initialize after joining session await client.join("session name", "jwt token", "name"); whiteboardClient = client.getWhiteboardClient(); // Check if whiteboard is available if (!whiteboardClient.isWhiteboardEnabled()) { console.warn("Whiteboard not available on this platform"); return; } // Set up event listeners client.on("peer-whiteboard-state-change", async (payload) => { const { action, userId } = payload; if (action === "Start") { await whiteboardClient.startWhiteboardView(whiteboardElement, userId); } else if (action === "Stop") { await whiteboardClient.stopWhiteboardView(); } }); client.on("whiteboard-status-change", (status) => { updateUIBasedOnStatus(status); }); // Start whiteboard as presenter (host/manager only) if (whiteboardClient.canStartWhiteboard()) { try { await whiteboardClient.startWhiteboardScreen(whiteboardElement); console.log("Whiteboard started successfully"); } catch (error) { console.error("Failed to start whiteboard:", error); } } // Export before stopping async function stopWithExport() { await whiteboardClient.exportWhiteboard("pdf", "session-whiteboard"); await whiteboardClient.stopWhiteboardScreen(); } ``` -------------------------------- ### Start cloud recording example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/recording.md JavaScript example showing how to start cloud recording using the RecordingClient instance. Handles the success case and checks for error code 7200 to indicate cloud recording is disabled. ```javascript const recording = client.getRecordingClient() recording.startCloudRecording().then(() => { console.log('recording started') }).catch((error) => { if (error.errorCode === 7200) console.log('cloud recording is disabled for this account') }) ``` -------------------------------- ### Get devices with promise and await examples Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/zoomvideo.md Enumerates media devices. The first example uses a promise chain; the second uses await with skipPermissionCheck to avoid the permission popup and filters for video input devices. Both handle errors. ```javascript // Basic ZoomVideo.getDevices().then(devices => { console.log(devices) }).catch(e => { console.log('get devices error!', e) }) ``` ```javascript // await with skip-check and error handling try { const devices = await ZoomVideo.getDevices(true) // no permission popup const cams = devices.filter(d => d.kind === 'videoinput') } catch (e) { console.log('get devices error!', e) } ``` -------------------------------- ### Set up annotation pen tool Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/screen-sharing/share-annotation.md Shows the steps to get the annotation controller, start annotation, and configure a pen tool with a width of 8 pixels. Uses AnnotationToolType.Pen. ```javascript // Step 1: Get the annotation controller const annotationController = client .getMediaStream() .getAnnotationController(); // Step 2: Start annotation await client.getMediaStream().startAnnotation(); // Step 3: Set up a pen tool await annotationController.setToolType(AnnotationToolType.Pen); await annotationController.setToolWidth(8); ``` -------------------------------- ### startLiveStream usage example (JavaScript) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/live-stream.md Example of starting a live stream and handling errors. Checks for error codes 7402 (already in progress) and 7400 (disabled for account). ```JavaScript const liveStream = client.getLiveStreamClient() liveStream.startLiveStream(streamUrl, streamKey, broadcastUrl) .then(() => console.log('live stream started')) .catch((error) => { if (error.errorCode === 7402) console.log('a live stream is already in progress') else if (error.errorCode === 7400) console.log('live streaming is disabled for this account') }) ``` -------------------------------- ### Pre-join audio check Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/preview.md JavaScript example showing how to create a local audio track, start it, test speaker and microphone, and stop. ```javascript // Pre-join audio check const audioTrack = ZoomVideo.createLocalAudioTrack() await audioTrack.start() const speakerTest = audioTrack.testSpeaker({ sampleAudioUrl: '/assets/sample.mp3', onAnalyseFrequency: (freq) => drawVisualizer(freq), }) // stop and clean up when done speakerTest.stop() speakerTest.destroy() const micTest = audioTrack.testMicrophone({ recordAndPlay: true, maxRecordDuration: 10 }) micTest.stopRecording() await audioTrack.stop() ``` -------------------------------- ### startVideo with virtual background and error handling Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/stream-video.md Starts video capture with HD resolution and a virtual background image. The first example uses try/catch to log errors. The second example uses .catch() to handle the specific error code 6100 (VIDEO_CAMERA_PERMISSION_DENIED) and opens camera permission settings. ```javascript try { await stream.startVideo({ hd: true, virtualBackground: { imageUrl: 'https://example.com/bg.jpg' }, }) } catch (error) { console.log(error) } // error handling by code stream.startVideo({ cameraId: cam.deviceId }).catch((e) => { if (e.errorCode === 6100) openCameraPermissionSettings() }) ``` -------------------------------- ### Handle active-share-change and startShareScreen Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/stream-share.md JavaScript example showing how to listen for the 'active-share-change' event to start or stop the share view, and how to call startShareScreen with the optimizedForSharedVideo option. It also handles the 'required extension' rejection by opening the extension URL. ```javascript client.on('active-share-change', (payload) => { if (payload.state === 'Active') { stream.startShareView(canvas, payload.activeUserId) } else if (payload.state === 'Inactive') { stream.stopShareView() } }) stream.startShareScreen(canvas, { optimizedForSharedVideo: true }).catch((e) => { if (e.reason === 'required extension') window.open(e.extensionUrl) }) ``` -------------------------------- ### Pre-join camera preview with virtual background Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/preview.md JavaScript example showing how to create a local video track, start preview with a virtual background, switch camera, update virtual background, and stop. ```javascript // Pre-join camera preview with virtual background const videoTrack = ZoomVideo.createLocalVideoTrack() await videoTrack.start(document.querySelector('#preview'), { imageUrl: 'https://example.com/bg.jpg', }) await videoTrack.switchCamera(cameras[1].deviceId) await videoTrack.updateVirtualBackground('blur') // cleanup await videoTrack.stop() ``` -------------------------------- ### Start voice translator with event listener Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/voice-translator.md JavaScript example that listens for the 'voice-translator-started' event and then starts the voice translator. Success is signaled by the event. ```javascript client.on('voice-translator-started', (payload) => { console.log('Voice translator started receiving audio') }) const vt = client.getVoiceTranslatorClient() vt.startVoiceTranslator() ``` -------------------------------- ### Incoming live stream usage example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/incoming-live-stream.md JavaScript example showing the full workflow: bind a stream, wait for RTMP connection via the 'incoming-live-stream-status' event, start the virtual participant, then stop and unbind. Requires a stream created via the Zoom OpenAPI and streaming software configured with stream_url and stream_key. ```javascript const incomingLiveStream = client.getIncomingLiveStreamClient() // 1. bind the stream created via the Zoom OpenAPI await incomingLiveStream.bindIncomingLiveStream(streamId) // 2. configure OBS/vMix with stream_url + stream_key and start pushing video // 3. wait for RTMP connection, then start the virtual participant client.on('incoming-live-stream-status', async (status) => { const { isRTMPConnected, isStreamPushed } = status if (isRTMPConnected && !isStreamPushed) { await incomingLiveStream.startIncomingLiveStream(status.streamId) } else if (!isRTMPConnected) { console.log('streaming software disconnected') } }) // 4. cleanup await incomingLiveStream.stopIncomingLiveStream(streamId) await incomingLiveStream.unbindIncomingLiveStream(streamId) ``` -------------------------------- ### CommandChannel usage example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/command.md JavaScript example showing how to get the command channel, send messages to a specific user, by userKey or userGuid, broadcast to all sessions, handle errors with error codes 7103 and 7104, and receive messages via the 'command-channel-message' event. ```javascript const cmdChannel = client.getCommandClient() // send to a specific user in the current session cmdChannel.send('test', userId) // send to a user by external key or guid (may be in another session) cmdChannel.send('test', { userKey: 'my-key' }) cmdChannel.send('test', { userGuid: 'xxxx' }) // broadcast to the main session and all subsessions cmdChannel.send('test', { scope: 'all' }) .then((msg) => console.log('sent, msgid:', msg.msgid)) .catch((v) => { if (v.errorCode === 7103) console.log('message too long (max 512 bytes)') else if (v.errorCode === 7104) console.log('command channel is not ready') }) // receive messages client.on('command-channel-message', (payload) => { console.log('from %s: %s', payload.senderId, payload.text) }) ``` -------------------------------- ### Start cloud recording Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/recording.md Starts cloud recording using the cloudRecording.startCloudRecording() method. ```javascript cloudRecording.startCloudRecording(); ``` -------------------------------- ### Install Video SDK with npm Source: https://github.com/zoom/videosdk-web/blob/main/README.md Installs the @zoom/videosdk package in your frontend project. ```bash $ npm install @zoom/videosdk --save ``` -------------------------------- ### Install Zoom Video SDK and jsrsasign Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/framework-integration/nuxtjs.md Install the SDK and jsrsasign for JWT signing, plus TypeScript types for jsrsasign. ```bash npm install @zoom/videosdk jsrsasign npm install -D @types/jsrsasign ``` -------------------------------- ### Basic and ZFG init examples Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/videoclient.md JavaScript examples for initializing the VideoClient. The first uses default Global assets with patchJsMedia enabled. The second uses a Zoom for Government (ZFG) web endpoint and explicit webEndpoint. ```javascript // Basic init const result = client.init('en-US', 'Global', { patchJsMedia: true }) // ZFG (Zoom for Government) init with explicit web endpoint client.init('en-US', 'https://source.zoomgov.com/videosdk/1.11.0/lib', { webEndpoint: 'www.zoomgov.com', }) ``` -------------------------------- ### isLiveStreamEnabled usage example (JavaScript) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/live-stream.md Example of checking if live streaming is enabled before starting it. ```JavaScript if (liveStream.isLiveStreamEnabled()) { await liveStream.startLiveStream(streamUrl, streamKey, broadcastUrl) } ``` -------------------------------- ### Check system requirements and initialize (JSX) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/browser-support.md Use this JSX example to check for video and audio support before initializing the Zoom Video SDK. It uses async/await syntax for init and join calls, and only proceeds if both video and audio are supported. ```jsx import ZoomVideo from "@zoom/videosdk"; const client = ZoomVideo.createClient(); let stream; if ( ZoomVideo.checkSystemRequirements().video && ZoomVideo.checkSystemRequirements().audio ) { await client.init("en-US", "Global", { patchJsMedia: true }); await client.join(topic, token, userName, password); stream = client.getMediaStream(); } ``` -------------------------------- ### Import and create client with init and join Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/zoomvideo.md Shows the default import and the singleton client creation. The client is initialized with locale, language, and options, then joins a session and accesses the media stream. ```javascript import ZoomVideo from '@zoom/videosdk' const client = ZoomVideo.createClient() client.init('en-US', 'Global', { patchJsMedia: true }) client.join(topic, token, userName).then(() => { const stream = client.getMediaStream() }) ``` -------------------------------- ### Complete incoming live stream integration example Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/incoming-live-stream.md This example shows the full workflow for integrating an incoming live stream: bind the stream, configure OBS/vMix, react to status changes, subscribe to the stream's video, and clean up on session end. It uses the client's getIncomingLiveStreamClient() and event handlers for 'incoming-live-stream-status' and 'user-added'. ```javascript const streamId = "abc123def456"; // stream_id from POST /v2/videosdk/stream_ingestions // Retrieve client after joining the session const incomingLiveStream = client.getIncomingLiveStreamClient(); // 1. Bind the stream await incomingLiveStream.bindIncomingLiveStream(streamId); // 2. Configure OBS/vMix with stream_url + stream_key, then start streaming // 3. React to status changes client.on("incoming-live-stream-status", async (payload) => { const { isRTMPConnected, isStreamPushed, streamId } = payload; if (isRTMPConnected && !isStreamPushed) { await incomingLiveStream.startIncomingLiveStream(streamId); console.log("Incoming stream is now a virtual participant"); } }); // 4. Subscribe to the stream's video when the participant joins client.on("user-added", (participants) => { const streamUser = participants.find((p) => p.isRtmpUser); if (streamUser) { client .getMediaStream() .attachVideo(streamUser.userId, VideoQuality.Video_720P) .then((userVideo) => { document .querySelector("video-player-container") .appendChild(userVideo); }); } }); // 5. On session end, stop the virtual participant if active // unbind is triggered via incoming-live-stream-status once isRTMPConnected becomes false async function cleanup() { const { isStreamPushed } = incomingLiveStream.getIncomingLiveStreamStatus(); if (isStreamPushed) { await incomingLiveStream.stopIncomingLiveStream(streamId); } // Ask the user to stop pushing in their streaming software. // unbindIncomingLiveStream will be called by the incoming-live-stream-status handler above // once isRTMPConnected becomes false. } ``` -------------------------------- ### Get any user's audio status Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/audio/audio.md Checks the audio status of a specific user by getting the user object and inspecting the 'muted' property. Note: the example uses 'currentUser' but should reference the fetched user. ```javascript const user = client.getUser(userId); if (currentUser.muted === false) { console.log("User is unmuted"); } else { console.log("User is muted"); } ``` -------------------------------- ### client.init(language, theme, options) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/sessions.md Initializes the Video SDK client. Must be called before joining a session. Returns a promise that must resolve before calling join. ```APIDOC ## client.init(language, theme, options) ### Description Initializes the Video SDK client. Must be called before joining a session. Returns a promise that must resolve before calling join. ### Method init ### Parameters - **language** (string) - Required - The language code for the SDK UI. - **theme** (string) - Required - The theme for the SDK UI. - **options** (object) - Optional - Initialization options. - **patchJsMedia** (boolean) - Optional - Set to true to automatically receive non-breaking enhancements and fixes. - **stayAwake** (boolean) - Optional - Prevents devices from sleeping while the user is in a session. - **leaveOnPageUnload** (boolean) - Optional - Removes the user from the session when they refresh or close the page. ### Example javascript client.init("en-US", "Global", { patchJsMedia: true }) ``` -------------------------------- ### Client initialization with InitOptions Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/configuration.md Shows how to create a ZoomVideo client and initialize it with the 'en-US' language, 'Global' dependent assets, and an options object that enables patchJsMedia, leaveOnPageUnload, and enforceMultipleVideos with disableRenderLimits. The result's type indicates if initialization failed. ```JavaScript import ZoomVideo from '@zoom/videosdk' const client = ZoomVideo.createClient() const result = client.init('en-US', 'Global', { patchJsMedia: true, leaveOnPageUnload: true, enforceMultipleVideos: { disableRenderLimits: true }, }) if (result.type) console.log('init failed:', result.reason) ``` -------------------------------- ### Check system requirements and initialize (JavaScript) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/browser-support.md Use this JavaScript example to check for video and audio support before initializing the Zoom Video SDK. It calls ZoomVideo.checkSystemRequirements() and only proceeds if both video and audio are supported. The example uses promise-based init and join calls, and logs errors to the console. ```javascript import ZoomVideo from "@zoom/videosdk"; const client = ZoomVideo.createClient(); let stream; if ( ZoomVideo.checkSystemRequirements().video && ZoomVideo.checkSystemRequirements().audio ) { client .init("en-US", "Global", { patchJsMedia: true }) .then(() => { client .join(topic, token, userName, password) .then(() => { stream = client.getMediaStream(); }) .catch((error) => { console.log(error); }); }) .catch((error) => { console.log(error); }); } ``` -------------------------------- ### Set original audio balance to 0.3 Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/voice-translator.md JavaScript example that sets the audio balance to 0.3, meaning mostly translated audio. Must be started first. ```javascript vt.setOriginalAudioBalance(0.3) // mostly translated audio ``` -------------------------------- ### Remote control workflow (request, approve, launch, start, stop) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/stream-camera-processor.md Five-step workflow for remote control: controlling user requests, controlled user approves (only when sharing entire screen), controlled user launches app after install, controlling user starts with viewport, and either side stops. ```javascript // step 1 — controlling user if (stream.isTargetShareSupportRemoteControl(userId)) stream.requestRemoteControl() // step 2 — controlled user (sharing entire screen only) client.on('remote-control-request-change', (payload) => { if (payload.isSharingEntireScreen) stream.approveRemoteControl(payload.userId) }) // step 3 — controlled user, app lifecycle client.on('remote-control-app-status-change', (payload) => { if (payload === RemoteControlAppStatus.Uninstalled) { // prompt download; after install call: stream.launchRemoteControlApp() } }) // step 4 — controlling user client.on('remote-control-approved-change', (payload) => { if (payload.state === ApprovedState.Approved) stream.startRemoteControl(viewport) }) // step 5 — stop from either side stream.giveUpRemoteControl() // controlling user stream.stopRemoteControl() // controlled user ``` -------------------------------- ### Create local audio and video tracks for preview Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/zoomvideo.md Shows the pre-join device preview flow: create an audio track, start it, test the speaker, then create a video track, start it on a preview element, and stop it. ```javascript // Device preview flow (pre-join camera/mic check) const audioTrack = ZoomVideo.createLocalAudioTrack() await audioTrack.start() audioTrack.testSpeaker({ speakerId: 'default' }) const videoTrack = ZoomVideo.createLocalVideoTrack() await videoTrack.start(document.querySelector('#preview')) await videoTrack.stop() ``` -------------------------------- ### startRealTimeMediaStreams() Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/real-time-media-streams.md Starts real-time media streams. Throws specific exception codes for not enabled, invalid state, or breakout room restrictions. ```APIDOC ## startRealTimeMediaStreams() ### Description Starts real-time media streams. ### Method function startRealTimeMediaStreams(): ExecutedResult; ### Return Value - **ExecutedResult** - The result of the start operation. ### Exceptions - **REAL_TIME_MEDIA_STREAMS_NOT_ENABLED** (8100) - Feature not enabled in the account setting. - **REAL_TIME_MEDIA_STREAMS_INVALID_STATE** (8101) - State mismatch. - **REAL_TIME_MEDIA_STREAMS_NOT_SUPPORTED_IN_BREAKOUT_ROOM** (8102) - Not supported in a breakout room. ``` -------------------------------- ### startVideo(option?) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/stream-video.md Starts capturing video from a specified camera. Supports custom dimensions, virtual backgrounds, masks, PTZ, media files, and custom constraints. Rejects with specific error codes on failure. ```APIDOC ## startVideo(option?) ### Description Starts capturing video from a specified camera. There is no default timeout for camera permission. ### Method Function ### Signature ```ts function startVideo(option?: CaptureVideoOption): ExecutedResult; ``` ### Parameters - **option** (CaptureVideoOption) - Optional - See options below. #### CaptureVideoOption Fields - **cameraId** (typeof MobileVideoFacingMode | string) - Optional - Camera device ID, or `'user'`/`'environment'` facing mode on mobile. - **captureWidth** / **captureHeight** (number) - Optional - Custom dimensions (non-standard aspect ratios only; use `hd`/`fullHd` for 720p/1080p). - **mirrored** (boolean) - Optional - Mirror self view. - **videoElement** (HTMLVideoElement) - Optional - Deprecated since 2.0.0; use `stream.attachVideo` for self-view. Only Android / non-SharedArrayBuffer Chromium. - **hd** / **fullHd** (boolean) - Optional - Capture at 720p / 1080p. - **virtualBackground** ({ imageUrl: string | 'blur' | undefined; cropped?: boolean }) - Optional - VB image (HTTP(S), base64, or ObjectURL), `'blur'`, or `undefined`. - **mask** (MaskOption) - Optional - Mask config; mutually exclusive with virtual background. - **originalRatio** (boolean) - Optional - Keep original aspect ratio (default crops to 16:9). - **ptz** (boolean) - Optional - Enable Pan-Tilt-Zoom when capturing. - **mediaFile** (MediaPlaybackFile) - Optional - Play a media file as video input. - **fps** (number) - Optional - Max FPS, 10–30. Default 24. - **customVideoConstraints** (MediaTrackConstraints) - Optional - Overrides `cameraId`/`captureWidth`/`captureHeight`/`fps` for the current camera (since 2.2.10). ### Error Codes Rejects with: `ExceptionCode.VIDEO_CAMERA_PERMISSION_DENIED` (6100), `VIDEO_NO_CAMERA` (6101), `VIDEO_MISMATCH_CAMERA` (6102), `VIDEO_CAMERA_TAKEN` (6103), `VIDEO_VB_INITIALIZE_ERROR` (6104), `VIDEO_CAPTURE_LOADING` (6105), `VIDEO_VB_UNSUPPORTED` (6107), `VIDEO_VB_PROCESSOR_CONFLICT` (6108), `VIDEO_MISMATCH_STATE` (6109), `VIDEO_ESTABLISH_STREAM_ERROR` (6110); documented reason strings also include `CAN_NOT_DETECT_CAMERA`, `CAN_NOT_FIND_CAMERA`, `VIDEO_USER_FORBIDDEN_CAPTURE`, `VIDEO_CAMERA_IS_TAKEN`. ### Request Example ```js try { await stream.startVideo({ hd: true, virtualBackground: { imageUrl: 'https://example.com/bg.jpg' }, }) } catch (error) { console.log(error) } // error handling by code stream.startVideo({ cameraId: cam.deviceId }).catch((e) => { if (e.errorCode === 6100) openCameraPermissionSettings() }) ``` ### Response Returns an `ExecutedResult` indicating success or failure. ``` -------------------------------- ### Get the incoming live stream client Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/incoming-live-stream.md Retrieve the incoming live stream client after joining a session. This client is used to bind, start, stop, and unbind the stream. ```javascript const incomingLiveStream = client.getIncomingLiveStreamClient(); ``` -------------------------------- ### Handle subsession-ask-for-help for hosts Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/subsessions.md Best practice example: implement a help request workflow for hosts, showing a dialog with options to join the subsession or postpone helping. ```javascript client.on("subsession-ask-for-help", (payload) => { showHelpDialog({ message: `${payload.displayName} in ${payload.subsessionName} needs help`, onJoin: () => subsessionClient.joinSubsession(payload.subsessionId), onLater: () => subsessionClient.postponeHelping(payload.userId), }); }); ``` -------------------------------- ### startWhiteboardScreen(element, options?) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/whiteboard.md Starts a whiteboard session as the presenter. Renders the whiteboard in the provided HTML element and optionally disables PDF export. ```APIDOC ## startWhiteboardScreen(element, options?) ### Description Starts a whiteboard session as the presenter. Renders the whiteboard in the provided HTML element and optionally disables PDF export. ### Method startWhiteboardScreen ### Signature ```ts function startWhiteboardScreen( element: HTMLElement, options?: StartWhiteboardOptions, ): ExecutedResult | Promise<string>; ``` ### Parameters - **element** (HTMLElement) - Required - HTML element where the whiteboard is rendered. - **options** (StartWhiteboardOptions) - Optional - `{ isDisableExport?: boolean }` — disable PDF export (default `false`, export enabled). ### Return `ExecutedResult | Promise<string>` ### Throws - `INVALID_OPERATION` (screen sharing in progress or whiteboard conflicts) - `INSUFFICIENT_PRIVILEGES` (no permission) - `INVALID_PARAMETERS` (bad docId/templateId) Corresponding `ExceptionCode` values: `WHITEBOARD_ACCOUNT_DISABLE` (8000), `WHITEBOARD_UNSUPPORTED` (8001), `WHITEBOARD_SCREEN_SHARE_CONFLICT` (8002), `WHITEBOARD_MISMATCH_STATE` (8003), `WHITEBOARD_HOST_PRIVILEGE_REQUIRED` (8004), `WHITEBOARD_INVALID_PARAMETER` (8005). ### Example ```js const whiteboard = client.getWhiteboardClient() if (whiteboard.canStartWhiteboard()) { await whiteboard.startWhiteboardScreen(document.querySelector('#wb')) } ``` ``` -------------------------------- ### Set speaking and listening languages Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/voice-translator.md JavaScript example that sets the speaking language to 'en' and the listening language to 'zh' (Chinese translation). The voice translator must be started first. ```javascript vt.setSpeakingLanguage('en') vt.setListeningLanguage('zh') // hear Chinese translation ``` -------------------------------- ### Join session and get media stream Source: https://github.com/zoom/videosdk-web/blob/main/README.md Starts or joins a session using client.join() with required parameters (topic, token, userName, password) and defines the stream for core features. ```js client.join(topic, token, userName, password).then(() => { stream = client.getMediaStream() }).catch((error) => { console.log(error) }) ``` -------------------------------- ### Sample API response for dial-in information Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/pstn.md Example JSON response from the Create a session or Get session details API, showing dial-in fields such as session_id, session_number, session_password, and global_dial_in_numbers. ```json { "session_id": "sfk/aOFJSJSYhGwk1hnxgw==", "session_number": 97763643886, "session_name": "My session", "session_password": "123456", "passcode": "123456", "created_at": "2022-03-25T07:29:29Z", "settings": { "auto_recording": "cloud", "global_dial_in_countries": ["US"], "global_dial_in_numbers": [ { "country": "US", "country_name": "US", "number": "+1 1000200200", "type": "toll" } ] } } ``` -------------------------------- ### Get live stream client with client.getLiveStreamClient() Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/live-stream.md Use after joining a session to obtain the live stream client instance from the session client. This client is required for starting and stopping live streams. ```javascript const liveStreamClient = client.getLiveStreamClient(); ``` -------------------------------- ### Start and join a session with async/await Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/get_started.md Initializes the Video SDK client and joins a session using async/await syntax. Requires a session name, Video SDK JWT, username, and optional session passcode. The session name must match the 'tpc' in the JWT, and the host is the user with role 1. ```javascript import ZoomVideo from "@zoom/videosdk"; var client = ZoomVideo.createClient(); var stream; await client.init("en-US", "Global", { patchJsMedia: true }); await client.join( "sessionName", "VIDEO_SDK_JWT", "userName", "sessionPasscode", ); stream = client.getMediaStream(); ``` -------------------------------- ### Full lifecycle with status event Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/real-time-media-streams.md JavaScript example showing the full lifecycle: listening to status changes, starting, pausing, resuming, handling errors, and stopping. Also checks the final status. ```JavaScript // full lifecycle with the status event client.on('real-time-media-streams-status-change', (payload) => { console.log('RTMS status:', payload.status) }) try { await rtms.startRealTimeMediaStreams() await rtms.pauseRealTimeMediaStreams() await rtms.resumeRealTimeMediaStreams() } catch (error) { if (error.errorCode === 8100) console.log('real-time media streams are not enabled') else if (error.errorCode === 8102) console.log('not supported inside a breakout room') } finally { await rtms.stopRealTimeMediaStreams() } const status = rtms.getRealTimeMediaStreamsStatus() if (status !== RealTimeMediaStreamsStatus.Start) { console.log('streams are not currently running') } ``` -------------------------------- ### startVideo (HD) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/video/video-hd.md Starts video capture with HD (720p) quality by passing the `hd: true` property. ```APIDOC ## startVideo (HD) ### Description Starts video capture with HD (720p) quality by passing the `hd: true` property. ### Method startVideo ### Endpoint stream.startVideo({ hd: true }) ### Parameters #### Request Body - **hd** (boolean) - Required - Set to `true` to enable 720p video. ### Request Example ```javascript stream.startVideo({ hd: true }); ``` ### Response No response body documented. ``` -------------------------------- ### Switch speaker using stream.getSpeakerList() and stream.switchSpeaker() Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/audio/audio.md Get the list of available speakers and the active speaker, then switch to a desired device by passing its deviceId to stream.switchSpeaker(). The example switches to the first available speaker if any exist. ```javascript const speakers = stream.getSpeakerList(); const activeSpeakerId = stream.getActiveSpeaker(); // Example: Switch to the first available speaker if (speakers.length) { stream.switchSpeaker(speakers[0].deviceId); } ``` -------------------------------- ### startVideo (Full HD) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/video/video-hd.md Starts video capture with Full HD (1080p) quality by passing the `fullHd: true` property. ```APIDOC ## startVideo (Full HD) ### Description Starts video capture with Full HD (1080p) quality by passing the `fullHd: true` property. ### Method startVideo ### Endpoint stream.startVideo({ fullHd: true }) ### Parameters #### Request Body - **fullHd** (boolean) - Required - Set to `true` to enable 1080p video. ### Request Example ```javascript stream.startVideo({ fullHd: true }); ``` ### Response No response body documented. ``` -------------------------------- ### Switch microphone using stream.getMicList() and stream.switchMicrophone() Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/audio/audio.md Get the list of available microphones and the active microphone, then switch to a desired device by passing its deviceId to stream.switchMicrophone(). The example switches to the first available microphone if any exist. ```javascript const microphones = stream.getMicList(); const activeMicrophoneId = stream.getActiveMicrophone(); // Example: Switch to the first available microphone if (microphones.length) { stream.switchMicrophone(microphones[0].deviceId); } ``` -------------------------------- ### init(language, dependentAssets, options?) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/videoclient.md Initializes the SDK before joining a session. Requires an SDK key & secret-derived JWT for authorization. ```APIDOC ## init(language, dependentAssets, options?) ### Description Initializes the SDK before joining a session. Authorization uses an SDK key & secret-derived JWT. ### Method Function call ### Signature ```ts function init( language: string, dependentAssets: string | 'CDN' | 'Global' | 'CN', options?: InitOptions, ): ExecutedResult; ``` ### Parameters - **language** (string) - Required - Language of the Video SDK interface. Default: `'en-US'`. - **dependentAssets** (string | 'CDN' | 'Global' | 'CN') - Required - Source path for WebWorker/WebAssembly assets. Default: `'Global'`. - **options** (InitOptions) - Optional - Additional init settings (`patchJsMedia`, `enforceMultipleVideos`, ...). ### Return `ExecutedResult` (`Promise<'' | ExecutedFailure>`) ### Error Handling Rejects with ExceptionCode: `CLIENT_PLATFORM_UNSUPPORTED` (5000), `CLIENT_DEPENDENT_ASSETS_INACCESSIBLE` (5001). ### Request Example ```js // Basic init const result = client.init('en-US', 'Global', { patchJsMedia: true }) // ZFG (Zoom for Government) init with explicit web endpoint client.init('en-US', 'https://source.zoomgov.com/videosdk/1.11.0/lib', { webEndpoint: 'www.zoomgov.com', }) ``` ``` -------------------------------- ### JavaScript: Start Video and Attach Self View (Async/Await) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/video/video.md Alternative async/await version of starting video and attaching the self view. Also requires a user gesture to avoid browser blocking camera access. ```javascript await stream.startVideo(); let userVideo = await stream.attachVideo( client.getCurrentUserInfo().userId, RESOLUTION, ); document.querySelector("video-player-container").appendChild(userVideo); ``` -------------------------------- ### canStartRealTimeMediaStreams() Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/real-time-media-streams.md Checks whether the current user is allowed to start real-time media streams. Only the host can start them, and they cannot be started in a breakout room. ```APIDOC ## canStartRealTimeMediaStreams() ### Description Whether the current user can start them. Only the host can start, and they cannot be started in a breakout room. ### Method function canStartRealTimeMediaStreams(): boolean; ### Return Value - **boolean** - True if the current user can start real-time media streams, otherwise false. ``` -------------------------------- ### Start broadcast streaming with error handling Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/broadcast-streaming.md Checks if broadcast streaming is enabled, then starts it. Catches error code 7901 (BROADCAST_STREAMING_MISMATCH_STATE) to log that the broadcast cannot start in the current state. ```javascript const broadcast = client.getBroadcastStreamingClient() if (broadcast.isBroadcastStreamingEnable()) { try { await broadcast.startBroadcast() } catch (error) { if (error.errorCode === 7901) console.log('cannot start in the current state') } } ``` -------------------------------- ### Complete subsession event listener example Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/subsessions.md A comprehensive example showing how to set up event listeners for subsession state changes, invitations, countdown, help requests, help responses, and broadcast messages. It uses the Zoom Video SDK client and subsession client. ```javascript const zmClient = ZoomVideo.createClient(); const subsessionClient = zmClient.getSubsessionClient(); // Track subsession state client.on("subsession-state-change", (payload) => { updateSubsessionUI(payload.status); }); // Handle invitations client.on("subsession-invite-to-join", (payload) => { showInviteDialog(payload.subsessionName, () => { subsessionClient.joinSubsession(payload.subsessionId); }); }); // Display countdown client.on("subsession-countdown", (payload) => { updateCountdownDisplay(payload.countdown); }); // Host: handle help requests if (zmClient.isHost()) { client.on("subsession-ask-for-help", (payload) => { showHelpRequest(payload.displayName, payload.subsessionName, () => { subsessionClient.joinSubsession(payload.subsessionId); }); }); } // User: handle help response client.on("subsession-ask-for-help-response", (payload) => { showHelpResponseMessage(payload.result); }); // Display broadcasts client.on("subsession-broadcast-message", (payload) => { showBroadcastNotification(payload.senderName, payload.message); }); ``` -------------------------------- ### startAudio(options?) Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/stream-audio.md Joins audio by microphone and speaker. Cannot join via computer audio if already on a phone. Returns ExecutedResult. ```APIDOC ## startAudio(options?) ### Description Joins audio by microphone and speaker. Cannot join via computer audio if already on a phone. ### Method function ### Signature `function startAudio(options?: AudioOption): ExecutedResult;` ### Parameters #### options (AudioOption) - Optional - `speakerOnly` (boolean) - Join with speaker only; microphone not connected. - `autoStartAudioInSafari` (boolean) - `true` only for auto-starting audio without a user gesture on Desktop Safari (macOS 15.2–16.0); otherwise `false`/unset. - `mute` (boolean) - Join with microphone muted. - `backgroundNoiseSuppression` (boolean) - Suppress background noise (dog barking, fans, pen tapping…). High CPU; needs `SharedArrayBuffer` for WASM audio. - `syncButtonsOnHeadset` (boolean) - Sync mute state with headsets from AVer, Crestron, Jabra, Logitech, Plantronics, Polycom, Shure, Yamaha, Yealink. - `mediaFile` (MediaPlaybackFile) - Use a media file as audio input (`{ url, currentTime?, loop?, playback? }`). - `originalSound` (boolean | { hifi?: boolean; stereo?: boolean }) - Original sound; conflicts with `backgroundNoiseSuppression`. - `microphoneId` (string) - Microphone device ID (default: system). - `speakerId` (string) - Speaker device ID (default: system). - `highBitrate` (boolean) - 128 kbps bitrate. - `customAudioConstraints` (MediaTrackConstraints) - Overrides `microphoneId`/`backgroundNoiseSuppression`/`originalSound` for the current microphone only (`@since 2.4.5`). ### Return Value `ExecutedResult` = `Promise<'' | ExecutedFailure>` ### Errors - Rejects `{ type:'INSUFFICIENT_PRIVILEGES', reason:'AUDIO_CAPTURE_FAILED' }` when microphone access is blocked. - Rejects `ExceptionCode.AUDIO_IN_PSTN` (6012), `AUDIO_ENCODING_REQUIRED` (6013, legacy Safari), `AUDIO_CAPTURE_LOADING` (6011). ### Example ```js await client.init('en-US', 'Global') await client.join(topic, token, 'Grace') const stream = client.getMediaStream() await stream.startAudio({ mute: true, backgroundNoiseSuppression: true }) // error handling stream.startAudio({ microphoneId: mic.deviceId }).catch((e) => { if (e.reason === 'AUDIO_CAPTURE_FAILED') showMicPermissionUI() }) ``` ``` -------------------------------- ### startLiveTranscription Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/transcription-translation.md Starts live transcription and translation. After starting, you can set the translation and speaking languages. ```APIDOC ## startLiveTranscription ### Description Starts live transcription and translation. After starting, you can set the translation and speaking languages. ### Method - `liveTranscriptionTranslation.startLiveTranscription()` ### Parameters None ### Returns - Promise that resolves when transcription starts. ### Example ```javascript liveTranscriptionTranslation.startLiveTranscription().then(() => { liveTranscriptionTranslation.setTranslationLanguage("ja"); liveTranscriptionTranslation.setSpeakingLanguage("ja"); }); ``` ```javascript await liveTranscriptionTranslation.startLiveTranscription(); liveTranscriptionTranslation.setTranslationLanguage("ja"); liveTranscriptionTranslation.setSpeakingLanguage("ja"); ``` ``` -------------------------------- ### Start virtual background with image URL Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/video/video-advanced.md Pass an image URL hosted from your domain to the `startVideo` function to set a virtual background on desktop browsers. Requires `SharedArrayBuffer` (SAB) enabled for better performance or the `enforceVirtualBackground` init option set to `true`. ```javascript stream.startVideo({ virtualBackground: { imageUrl: "./my-background.jpg" } }); ``` -------------------------------- ### startWhiteboardView Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/features/whiteboard.md Starts viewing a whiteboard session as a viewer. Used when another user starts presenting a whiteboard. ```APIDOC ## startWhiteboardView(whiteboardElement, userId) ### Description Starts viewing a whiteboard session as a viewer. Used when another user starts presenting a whiteboard. ### Method startWhiteboardView ### Endpoint whiteboardClient.startWhiteboardView(whiteboardElement, userId) ### Parameters #### Request Body - **whiteboardElement** (HTMLDivElement) - Required - The HTML element to use as the mounting point. - **userId** (string) - Required - The user ID of the presenter. ### Request Example ```javascript await whiteboardClient.startWhiteboardView(whiteboardElement, userId); ``` ### Response #### Success Response No return value. The whiteboard view is started. #### Response Example ```javascript await whiteboardClient.startWhiteboardView(whiteboardElement, userId); ``` ``` -------------------------------- ### createSubsessions usage example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/subsession.md JavaScript example that creates three subsessions with automatic allocation and logs their names. ```javascript const subsessions = await subsession.createSubsessions(3, SubsessionAllocationPattern.Automatically) console.log(subsessions.map(s => s.subsessionName)) ``` -------------------------------- ### mediaStream.startAudio({ mediaFile: { url } }) Source: https://github.com/zoom/videosdk-web/blob/main/skill/references/audio/audio-advanced.md Starts playing an audio media file in the session. Pass the audio URL as an object in the `mediaFile` property. ```APIDOC ## mediaStream.startAudio({ mediaFile: { url } }) ### Description Starts playing an audio media file in the session. Pass the audio URL as an object in the `mediaFile` property. ### Method Function ### Endpoint N/A (SDK function) ### Parameters - **mediaFile.url** (string) - Required - The URL of the audio file to play. ### Request Example ```javascript await mediaStream.startAudio({ mediaFile: { url: "https://example.com/audio.mp3" }, }); ``` ### Response No return value. ``` -------------------------------- ### openSubsessions usage example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/subsession.md JavaScript example that opens subsessions with a timer enabled for 600 seconds and auto-join enabled. ```javascript await subsession.openSubsessions(subsessions, { isTimerEnabled: true, timerDuration: 600, isAutoJoinSubsession: true, }) ``` -------------------------------- ### LiveVideo event handling example Source: https://github.com/zoom/videosdk-web/blob/main/_autodocs/api-reference/zoom-broadcast-streaming.md JavaScript example showing how to listen for 'resolution-change', 'rewind-total-time', and 'rewind-config' events on a live-video element. The event details provide old and new resolution values, max rewind time, and rewind support status. ```JavaScript const liveVideo = document.querySelector('live-video') liveVideo.addEventListener('resolution-change', (event) => { const { oldVal, newVal } = event.detail console.log(`resolution changes from ${oldVal}P to ${newVal}P`) }) liveVideo.addEventListener('rewind-total-time', (event) => { console.log(`Current max rewind time: ${event.detail}`) }) liveVideo.addEventListener('rewind-config', (event) => { console.log(`Current streaming supports rewind: ${event.detail}`) }) ```