### Start Screen Share with Options Source: https://context7.com/daily-co/daily-js/llms.txt Starts screen sharing with specific display media options for video quality and audio capture, and optimizes for motion or detail. ```javascript // Start screen share with options callObject.startScreenShare({ displayMediaOptions: { video: { width: { max: 1920 }, height: { max: 1080 }, frameRate: { max: 30 } }, audio: true, selfBrowserSurface: 'include', surfaceSwitching: 'include' }, screenVideoSendSettings: 'motion-optimized' // or 'detail-optimized' }); ``` -------------------------------- ### Start Screen Share with Custom Media Stream Source: https://context7.com/daily-co/daily-js/llms.txt Starts screen sharing using a pre-acquired media stream from `navigator.mediaDevices.getDisplayMedia`. ```javascript // Start screen share with custom media stream const displayStream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: true }); callObject.startScreenShare({ mediaStream: displayStream }); ``` -------------------------------- ### Import and Initialize Daily.js Source: https://github.com/daily-co/daily-js/blob/daily-js-releases/test/module-script.html Import the Daily library and create a new instance. This is the basic setup for using Daily.js functionalities. ```javascript import Daily from '../dist/daily-esm.js'; let daily = new Daily(); document.getElementById('rplx').innerText = daily.sayHello(); ``` -------------------------------- ### Start and Manage Custom Tracks in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Use this to send additional custom audio or video streams beyond the standard camera and microphone. Ensure the track is properly created before starting. ```javascript // Get a custom video track (e.g., from canvas) const canvas = document.getElementById('my-canvas'); const canvasStream = canvas.captureStream(30); const customVideoTrack = canvasStream.getVideoTracks()[0]; // Start sending custom track const trackName = await callObject.startCustomTrack({ track: customVideoTrack, trackName: 'canvas-video', mode: 'speech' // or 'music' for audio tracks }); console.log('Custom track started with name:', trackName); // Start custom audio track const audioContext = new AudioContext(); const destination = audioContext.createMediaStreamDestination(); const customAudioTrack = destination.stream.getAudioTracks()[0]; await callObject.startCustomTrack({ track: customAudioTrack, trackName: 'custom-audio', mode: { bitrate: 128000, stereo: true } }); // Stop custom track await callObject.stopCustomTrack('canvas-video'); // Access custom tracks on participants const participant = callObject.participants()['remote-session-id']; if (participant.tracks['canvas-video']?.state === 'playable') { const customTrack = participant.tracks['canvas-video'].track; videoElement.srcObject = new MediaStream([customTrack]); } // Subscribe to custom tracks callObject.updateParticipant(sessionId, { setSubscribedTracks: { video: true, audio: true, custom: { 'canvas-video': true, 'custom-audio': true } } }); ``` -------------------------------- ### Start Basic Screen Share Source: https://context7.com/daily-co/daily-js/llms.txt Initiates screen sharing with default settings. Ensure the call object is properly initialized. ```javascript // Start basic screen share callObject.startScreenShare(); ``` -------------------------------- ### Start Cloud Recording Source: https://context7.com/daily-co/daily-js/llms.txt Initiates cloud recording with default or custom options for video dimensions, frame rate, bitrate, and layout. ```javascript // Start cloud recording with default layout callObject.startRecording(); ``` ```javascript // Start recording with custom options callObject.startRecording({ type: 'cloud', // 'cloud', 'raw-tracks', 'local', or 'cloud-audio-only' width: 1920, height: 1080, fps: 30, videoBitrate: 5000, layout: { preset: 'default', max_cam_streams: 9 } }); ``` ```javascript // Start with custom layout callObject.startRecording({ layout: { preset: 'active-participant' } }); ``` -------------------------------- ### Listen for Screen Share Events Source: https://context7.com/daily-co/daily-js/llms.txt Sets up listeners for events indicating the start, stop, or cancellation of a local screen share. ```javascript // Listen for screen share events callObject.on('local-screen-share-started', (event) => { console.log('Screen share started'); }); callObject.on('local-screen-share-stopped', (event) => { console.log('Screen share stopped'); }); callObject.on('local-screen-share-canceled', (event) => { console.log('Screen share was canceled by user'); }); ``` -------------------------------- ### Start Live Streaming Source: https://context7.com/daily-co/daily-js/llms.txt Initiates live streaming to RTMP endpoints with configurable quality and layout settings. Supports single or multiple destinations. ```javascript // Start live streaming to RTMP URL callObject.startLiveStreaming({ rtmpUrl: 'rtmp://live.twitch.tv/app/your-stream-key', width: 1920, height: 1080, fps: 30, videoBitrate: 4500, layout: { preset: 'default', max_cam_streams: 4 } }); ``` ```javascript // Stream to multiple endpoints callObject.startLiveStreaming({ endpoints: [ { endpoint: 'rtmp://live.twitch.tv/app/key1' }, { endpoint: 'rtmp://a.rtmp.youtube.com/live2/key2' } ], layout: { preset: 'active-participant' } }); ``` -------------------------------- ### Start Transcription Source: https://context7.com/daily-co/daily-js/llms.txt Initiates real-time transcription with default or custom settings for language, model, and filtering. ```javascript // Start transcription with default settings callObject.startTranscription(); ``` ```javascript // Start transcription with custom options callObject.startTranscription({ language: 'en', model: 'nova-2', profanity_filter: true, punctuate: true, endpointing: 500, // milliseconds of silence to end utterance redact: ['pci', 'ssn'], includeRawResponse: true }); ``` -------------------------------- ### Recording API Source: https://context7.com/daily-co/daily-js/llms.txt Start, manage, and stop cloud or local recordings of meetings. Configure recording layout and quality settings. ```APIDOC ## Recording API ### Description Manages cloud or local recording of meetings. Allows configuration of recording layout and quality settings. ### Methods - `startRecording(options)`: Starts a recording. Options include `type` ('cloud', 'raw-tracks', 'local', 'cloud-audio-only'), `width`, `height`, `fps`, `videoBitrate`, and `layout`. - `updateRecording(options)`: Updates the recording layout while a recording is active. Requires a `layout` object. - `stopRecording()`: Stops the active recording. ### Events - `recording-started`: Fired when recording begins. Provides `recordingId`. - `recording-stopped`: Fired when recording stops. - `recording-error`: Fired when a recording error occurs. Provides `errorMsg`. - `recording-data`: Fired during local recording. Provides `data` chunks (Uint8Array) and a `finished` boolean. ### Request Example (Start cloud recording with custom options) ```javascript callObject.startRecording({ type: 'cloud', width: 1920, height: 1080, fps: 30, videoBitrate: 5000, layout: { preset: 'default', max_cam_streams: 9 } }); ``` ### Request Example (Update recording layout) ```javascript callObject.updateRecording({ layout: { preset: 'single-participant', session_id: 'participant-session-id' } }); ``` ### Request Example (Stop recording) ```javascript callObject.stopRecording(); ``` ### Response Example (recording-started event) ```json { "recordingId": "your-recording-id" } ``` ``` -------------------------------- ### Monitor Audio Levels in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Start and stop observers for local and remote audio levels, retrieve current levels, and listen for updates. Also includes built-in active speaker detection. ```javascript // Start monitoring local audio level await callObject.startLocalAudioLevelObserver(100); // interval in ms ``` ```javascript // Check if observer is running const isRunning = callObject.isLocalAudioLevelObserverRunning(); ``` ```javascript // Get current local audio level (0.0 to 1.0) const level = callObject.getLocalAudioLevel(); ``` ```javascript // Listen for local audio level updates callObject.on('local-audio-level', (event) => { updateMicrophoneMeter(event.audioLevel); }); ``` ```javascript // Stop local audio level observer callObject.stopLocalAudioLevelObserver(); ``` ```javascript // Start monitoring remote participants' audio levels await callObject.startRemoteParticipantsAudioLevelObserver(100); ``` ```javascript // Get remote audio levels const remoteLevels = callObject.getRemoteParticipantsAudioLevel(); // { 'session-id-1': 0.5, 'session-id-2': 0.0, ... } ``` ```javascript // Listen for remote audio level updates callObject.on('remote-participants-audio-level', (event) => { for (const [sessionId, level] of Object.entries(event.participantsAudioLevel)) { updateSpeakingIndicator(sessionId, level > 0.1); } }); ``` ```javascript // Stop remote audio level observer callObject.stopRemoteParticipantsAudioLevelObserver(); ``` ```javascript // Active speaker detection (built-in) const activeSpeaker = callObject.getActiveSpeaker(); console.log('Current active speaker:', activeSpeaker.peerId); ``` ```javascript callObject.on('active-speaker-change', (event) => { console.log('New active speaker:', event.activeSpeaker.peerId); }); ``` -------------------------------- ### Handle Live Streaming Events Source: https://context7.com/daily-co/daily-js/llms.txt Listens for events related to the live streaming lifecycle, including start, updates, stop, and errors. ```javascript // Live streaming events callObject.on('live-streaming-started', (event) => { console.log('Live stream started'); }); callObject.on('live-streaming-updated', (event) => { console.log('Endpoint state:', event.endpoint, event.state); }); callObject.on('live-streaming-stopped', () => { console.log('Live stream stopped'); }); callObject.on('live-streaming-error', (event) => { console.error('Streaming error:', event.errorMsg); }); ``` -------------------------------- ### Get Room Information in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Retrieve details about the current room configuration and meeting session after joining. This includes room name, ID, and configuration settings. Optionally include default room configuration values. ```javascript const roomInfo = await callObject.room(); console.log('Room name:', roomInfo.name); console.log('Room ID:', roomInfo.id); console.log('Room config:', roomInfo.config); ``` ```javascript const fullInfo = await callObject.room({ includeRoomConfigDefaults: true }); ``` -------------------------------- ### Monitor Network Quality in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Get current network statistics and listen for changes in network quality during a call. Network states include 'good', 'warning', 'bad', and 'unknown'. ```javascript const stats = await callObject.getNetworkStats(); console.log('Network state:', stats.networkState); console.log('Stats:', stats.stats.latest); ``` ```javascript callObject.on('network-quality-change', (event) => { console.log('Network state:', event.networkState); console.log('Reasons:', event.networkStateReasons); console.log('Quality:', event.quality); }); ``` -------------------------------- ### Handle Track Events Source: https://context7.com/daily-co/daily-js/llms.txt Responds to events when media tracks (video or audio) start or stop. Includes logic to attach remote video tracks to DOM elements. ```javascript // Track events callObject.on('track-started', (event) => { const { participant, track, type } = event; if (type === 'video' && !participant.local) { // Attach remote video track to video element const videoEl = document.getElementById(`video-${participant.session_id}`); videoEl.srcObject = new MediaStream([track]); } }); callObject.on('track-stopped', (event) => { console.log(`Track stopped: ${event.type} from ${event.participant?.user_name}`); }); ``` -------------------------------- ### Handle Recording Events Source: https://context7.com/daily-co/daily-js/llms.txt Listens for events related to the recording lifecycle, including start, stop, and errors. For local recordings, it also handles data chunks. ```javascript // Listen for recording events callObject.on('recording-started', (event) => { console.log('Recording started:', event.recordingId); }); callObject.on('recording-stopped', (event) => { console.log('Recording stopped'); }); callObject.on('recording-error', (event) => { console.error('Recording error:', event.errorMsg); }); // For local recording, handle data chunks callObject.on('recording-data', (event) => { const { data, finished } = event; // data is a Uint8Array chunk recordingChunks.push(data); if (finished) { const blob = new Blob(recordingChunks, { type: 'video/webm' }); const url = URL.createObjectURL(blob); } }); ``` -------------------------------- ### Get Geographic Region and Network Topology in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Determine the current geographic region for the connection and retrieve the network topology, which can be 'sfu' or 'peer'. ```javascript const geo = await callObject.geo(); console.log('Current region:', geo.current); ``` ```javascript const topology = await callObject.getNetworkTopology(); console.log('Topology:', topology.topology); ``` -------------------------------- ### Get and Update Call Participants Source: https://context7.com/daily-co/daily-js/llms.txt Retrieve all participants, access local user details, and modify remote participant settings like subscribed tracks, media states, permissions, or eject them. Requires owner permissions for certain actions. ```javascript // Get all participants const participants = callObject.participants(); const localParticipant = participants.local; const remoteParticipants = Object.values(participants).filter(p => !p.local); // Access participant properties console.log('Local participant:', { sessionId: localParticipant.session_id, userName: localParticipant.user_name, videoState: localParticipant.tracks.video.state, audioState: localParticipant.tracks.audio.state, isOwner: localParticipant.owner }); ``` ```javascript // Update a remote participant's subscribed tracks callObject.updateParticipant(remoteSessionId, { setSubscribedTracks: { video: true, audio: true, screenVideo: true, screenAudio: false } }); ``` ```javascript // Mute a remote participant (requires owner permissions) callObject.updateParticipant(remoteSessionId, { setAudio: false, setVideo: false }); ``` ```javascript // Update participant permissions callObject.updateParticipant(remoteSessionId, { updatePermissions: { hasPresence: true, canSend: ['audio', 'video'], canAdmin: ['participants'] } }); ``` ```javascript // Eject a participant callObject.updateParticipant(remoteSessionId, { eject: true }); ``` ```javascript // Get participant counts const counts = callObject.participantCounts(); console.log(`Present: ${counts.present}, Hidden: ${counts.hidden}`); ``` -------------------------------- ### Get Meeting Session Information in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Access the meeting session summary, including its ID, and the current session state, which includes topology and custom data. Session data can be updated using 'shallow-merge' or 'replace'. ```javascript const session = callObject.meetingSessionSummary(); console.log('Session ID:', session.id); ``` ```javascript const state = callObject.meetingSessionState(); console.log('Topology:', state.topology); console.log('Session data:', state.data); ``` ```javascript callObject.setMeetingSessionData( { agenda: 'Project review', startTime: Date.now() }, 'shallow-merge' ); ``` ```javascript callObject.on('meeting-session-state-updated', (event) => { console.log('Session state updated:', event.meetingSessionState); }); ``` -------------------------------- ### Initialize and Say Hello with Daily.js Source: https://github.com/daily-co/daily-js/blob/daily-js-releases/test/basic-script.html Instantiates the Daily.js client and calls the sayHello method. Ensure the Daily.js library is loaded in the window context. ```javascript function run() { let daily = new window.Daily(); document.getElementById('rplx').innerText = daily.sayHello(); } ``` -------------------------------- ### Handle Transcription Events Source: https://context7.com/daily-co/daily-js/llms.txt Listens for transcription messages, start, stop, and error events, providing details about the transcription process. ```javascript // Listen for transcription messages callObject.on('transcription-message', (event) => { console.log(`${event.participantId}: ${event.text}`); console.log('Timestamp:', event.timestamp); console.log('Track type:', event.trackType); // 'cam-audio', 'screen-audio', etc. }); callObject.on('transcription-started', (event) => { console.log('Transcription started:', event.instanceId); console.log('Language:', event.language); console.log('Model:', event.model); }); callObject.on('transcription-stopped', (event) => { console.log('Transcription stopped by:', event.updatedBy); }); callObject.on('transcription-error', (event) => { console.error('Transcription error:', event.errorMsg); }); ``` -------------------------------- ### Transcription API Source: https://context7.com/daily-co/daily-js/llms.txt Start and manage real-time meeting transcription powered by Deepgram. Supports multiple languages and configuration options. ```APIDOC ## Transcription API ### Description Provides real-time speech-to-text transcription of meeting audio with support for multiple languages and configuration options. ### Methods - `startTranscription(options)`: Starts transcription. Options include `language`, `model`, `profanity_filter`, `punctuate`, `endpointing`, `redact`, and `includeRawResponse`. - `updateTranscription(options)`: Updates transcription participants. Requires a `participants` array of session IDs. - `stopTranscription()`: Stops the active transcription. ### Events - `transcription-message`: Fired for each transcribed message. Provides `participantId`, `text`, `timestamp`, and `trackType`. - `transcription-started`: Fired when transcription begins. Provides `instanceId`, `language`, and `model`. - `transcription-stopped`: Fired when transcription stops. Provides `updatedBy`. - `transcription-error`: Fired when a transcription error occurs. Provides `errorMsg`. ### Request Example (Start transcription with default settings) ```javascript callObject.startTranscription(); ``` ### Request Example (Start transcription with custom options) ```javascript callObject.startTranscription({ language: 'en', model: 'nova-2', profanity_filter: true, punctuate: true, endpointing: 500, redact: ['pci', 'ssn'], includeRawResponse: true }); ``` ### Request Example (Update transcription participants) ```javascript callObject.updateTranscription({ participants: ['session-id-1', 'session-id-2'] }); ``` ### Request Example (Stop transcription) ```javascript callObject.stopTranscription(); ``` ### Response Example (transcription-message event) ```json { "participantId": "participant-session-id", "text": "Hello, how are you?", "timestamp": 1678886400.123, "trackType": "cam-audio" } ``` ``` -------------------------------- ### Run Basic Require Test Source: https://github.com/daily-co/daily-js/blob/daily-js-releases/test/README.md Execute the basic require test file using Node.js. ```bash node test/basic-require.js ``` -------------------------------- ### Input Settings and Processors Source: https://context7.com/daily-co/daily-js/llms.txt Configure video background effects and audio noise cancellation processors. ```APIDOC ## Input Settings and Processors Configure video background effects and audio noise cancellation processors. The input settings API allows you to apply video processors (blur, background images) and audio processors (noise cancellation) to your local media tracks. ### Apply Background Blur ```javascript await callObject.updateInputSettings({ video: { processor: { type: 'background-blur', config: { strength: 0.8 } } } }); ``` ### Apply Background Image ```javascript await callObject.updateInputSettings({ video: { processor: { type: 'background-image', config: { source: 'https://example.com/background.jpg' } } } }); ``` ### Enable Noise Cancellation ```javascript await callObject.updateInputSettings({ audio: { processor: { type: 'noise-cancellation' } } }); ``` ### Remove All Processors ```javascript await callObject.updateInputSettings({ video: { processor: { type: 'none' } }, audio: { processor: { type: 'none' } } }); ``` ### Get Current Input Settings ```javascript const settings = await callObject.getInputSettings(); console.log('Video processor:', settings.video?.processor); console.log('Audio processor:', settings.audio?.processor); ``` ### Use Custom MediaStreamTrack as Video Source ```javascript const customTrack = myCustomVideoStream.getVideoTracks()[0]; await callObject.updateInputSettings({ video: { settings: { customTrack: customTrack } } }); ``` ``` -------------------------------- ### Configure Input Settings and Processors Source: https://context7.com/daily-co/daily-js/llms.txt Apply video effects like background blur or images, and enable audio noise cancellation for local media tracks. Allows using custom MediaStreamTracks and retrieving current settings. ```javascript // Apply background blur await callObject.updateInputSettings({ video: { processor: { type: 'background-blur', config: { strength: 0.8 } } } }); ``` ```javascript // Apply background image await callObject.updateInputSettings({ video: { processor: { type: 'background-image', config: { source: 'https://example.com/background.jpg' } } } }); ``` ```javascript // Enable noise cancellation await callObject.updateInputSettings({ audio: { processor: { type: 'noise-cancellation' } } }); ``` ```javascript // Remove all processors await callObject.updateInputSettings({ video: { processor: { type: 'none' } }, audio: { processor: { type: 'none' } } }); ``` ```javascript // Get current input settings const settings = await callObject.getInputSettings(); console.log('Video processor:', settings.video?.processor); console.log('Audio processor:', settings.audio?.processor); ``` ```javascript // Use custom MediaStreamTrack as video source const customTrack = myCustomVideoStream.getVideoTracks()[0]; await callObject.updateInputSettings({ video: { settings: { customTrack: customTrack } } }); ``` -------------------------------- ### Run Node Import Test Source: https://github.com/daily-co/daily-js/blob/daily-js-releases/test/README.md Execute the Node.js import test file using the experimental module loader. ```bash node --experimental-modules test/node-import.mjs ``` -------------------------------- ### Run Babel Import Test Source: https://github.com/daily-co/daily-js/blob/daily-js-releases/test/README.md Transform and run the import test file using Babel Node with the specified plugin. ```bash babel-node --plugins transform-es2015-modules-commonjs test/basic-import.js ``` -------------------------------- ### Initiate Dial-Out to SIP Endpoints in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Initiate outbound calls to SIP endpoints. Specify the SIP URI, display name, and optionally enable video and define codecs for audio and video. ```javascript // Dial out to SIP endpoint await callObject.startDialOut({ sipUri: 'sip:user@domain.com', displayName: 'Daily Meeting', video: true, // Enable video for SIP codecs: { audio: ['OPUS'], video: ['H264', 'VP8'] } }); ``` -------------------------------- ### Manage Event Listeners Source: https://context7.com/daily-co/daily-js/llms.txt Demonstrates how to add a specific event listener and then remove it using `off()`. Also shows how to set up a listener that only fires once using `once()`. ```javascript // Remove specific listener const handler = (event) => console.log(event); callObject.on('participant-joined', handler); callObject.off('participant-joined', handler); // One-time listener callObject.once('joined-meeting', (event) => { console.log('Joined (only fires once)'); }); ``` -------------------------------- ### Controlling Local Media Source: https://context7.com/daily-co/daily-js/llms.txt Toggle and configure local audio and video tracks including device selection. ```APIDOC ## Controlling Local Media Toggle and configure local audio and video tracks including device selection. The local media methods allow you to mute/unmute your camera and microphone, select specific devices, and configure input processing like background blur or noise cancellation. ### Check Current Local Media State ```javascript const isVideoOn = callObject.localVideo(); const isAudioOn = callObject.localAudio(); const isScreenShareVideoOn = callObject.localScreenVideo(); const isScreenShareAudioOn = callObject.localScreenAudio(); ``` ### Toggle Local Audio/Video ```javascript callObject.setLocalAudio(false); // Mute microphone callObject.setLocalVideo(true); // Turn on camera // Mute and force discard the audio track callObject.setLocalAudio(false, { forceDiscardTrack: true }); ``` ### Set Input Devices ```javascript await callObject.setInputDevicesAsync({ audioDeviceId: 'microphone-device-id', videoDeviceId: 'camera-device-id' }); ``` ### Set Output Device ```javascript await callObject.setOutputDeviceAsync({ outputDeviceId: 'speaker-device-id' }); ``` ### Get Current Device Info ```javascript const devices = await callObject.getInputDevices(); console.log('Camera:', devices.camera); console.log('Microphone:', devices.mic); console.log('Speaker:', devices.speaker); ``` ### Enumerate All Available Devices ```javascript const { devices: allDevices } = await callObject.enumerateDevices(); const cameras = allDevices.filter(d => d.kind === 'videoinput'); const microphones = allDevices.filter(d => d.kind === 'audioinput'); const speakers = allDevices.filter(d => d.kind === 'audiooutput'); ``` ### Cycle Through Cameras ```javascript const { device } = await callObject.cycleCamera(); console.log('Switched to camera:', device.label); ``` ``` -------------------------------- ### Joining a Meeting Source: https://context7.com/daily-co/daily-js/llms.txt Joins a Daily video call room and returns participant information on success. The `join()` method connects to a Daily room URL with optional configuration. It returns a Promise that resolves with all current participants when the join succeeds, or rejects with an error if the join fails. ```APIDOC ## Joining a Meeting Joins a Daily video call room and returns participant information on success. The `join()` method connects to a Daily room URL with optional configuration. It returns a Promise that resolves with all current participants when the join succeeds, or rejects with an error if the join fails. ### Parameters #### Request Body - **url** (string) - Required - The URL of the Daily room to join. - **token** (string) - Optional - A meeting token for authentication. - **userName** (string) - Optional - The display name for the participant. - **userData** (object) - Optional - Custom data associated with the participant. - **startVideoOff** (boolean) - Optional - Whether to start with video off. - **startAudioOff** (boolean) - Optional - Whether to start with audio off. - **receiveSettings** (object) - Optional - Settings for receiving media. - **base** (object) - Base receive settings. - **video** (object) - Video receive settings. - **layer** (number) - The desired video layer. - **screenVideo** (object) - Screen video receive settings. - **layer** (number) - The desired screen video layer. ### Request Example ```javascript const callObject = Daily.createCallObject(); // Basic join try { const participants = await callObject.join({ url: 'https://your-domain.daily.co/room-name' }); console.log('Joined meeting with participants:', participants); // { local: { session_id: 'abc123', user_name: 'John', local: true, ... }, 'xyz789': { ... } } } catch (error) { console.error('Failed to join:', error); } // Join with token and user settings const participants = await callObject.join({ url: 'https://your-domain.daily.co/private-room', token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', userName: 'Meeting Participant', userData: { role: 'presenter', company: 'Acme Inc' }, startVideoOff: false, startAudioOff: true, receiveSettings: { base: { video: { layer: 2 }, screenVideo: { layer: 2 } } } }); // Listen for join event callObject.on('joined-meeting', (event) => { console.log('Successfully joined:', event.participants); }); callObject.on('error', (event) => { console.error('Join failed:', event.errorMsg, event.error); }); ``` ### Response #### Success Response (200) - **participants** (object) - An object containing all current participants in the meeting. Each participant object includes details like `session_id`, `user_name`, and `local` status. #### Response Example ```json { "local": { "session_id": "abc123", "user_name": "John", "local": true, "video": true, "audio": true }, "xyz789": { "session_id": "xyz789", "user_name": "Jane", "local": false, "video": true, "audio": true } } ``` ``` -------------------------------- ### Run Pre-Call Network Quality Test in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Assess connection quality before joining a call. This test provides a 'good', 'warning', 'bad', or 'failed' result along with detailed metrics. The test can be stopped early if necessary. ```javascript const callObject = Daily.createCallObject(); await callObject.preAuth({ url: 'https://domain.daily.co/room' }); const results = await callObject.testCallQuality(); console.log('Test result:', results.result); console.log('Data:', results.data); ``` ```javascript callObject.stopTestCallQuality(); ``` -------------------------------- ### Monitor CPU Load in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Monitor the CPU load state, which can be 'low' or 'high', and listen for changes. The reason for the current state is also provided. ```javascript const cpuStats = await callObject.getCpuLoadStats(); console.log('CPU state:', cpuStats.cpuLoadState); console.log('Reason:', cpuStats.cpuLoadStateReason); ``` ```javascript callObject.on('cpu-load-change', (event) => { console.log('CPU load state changed:', event.cpuLoadState); }); ``` -------------------------------- ### Create Daily Call Object Source: https://context7.com/daily-co/daily-js/llms.txt Use `createCallObject()` to initialize a Daily call instance for custom video experiences. Configure options like URL, token, and user settings during creation. Check browser support before creating an object. ```javascript import Daily from '@daily-co/daily-js'; // Basic call object creation const callObject = Daily.createCallObject(); // Call object with configuration options const callObject = Daily.createCallObject({ url: 'https://your-domain.daily.co/room-name', token: 'your-meeting-token', userName: 'John Doe', startVideoOff: false, startAudioOff: false, dailyConfig: { micAudioMode: 'music', preferH264: true, } }); // Check browser support before creating const browserInfo = Daily.supportedBrowser(); if (browserInfo.supported) { const call = Daily.createCallObject(); } // browserInfo: { supported: true, mobile: false, name: 'Chrome', version: '120.0', supportsScreenShare: true, supportsVideoProcessing: true } ``` -------------------------------- ### Join Daily Meeting Source: https://context7.com/daily-co/daily-js/llms.txt Use the `join()` method on a call object to connect to a Daily room. It returns a Promise resolving with participants on success or rejecting with an error. Supports joining with tokens, user data, and specific receive settings. Listen for `joined-meeting` and `error` events. ```javascript const callObject = Daily.createCallObject(); // Basic join try { const participants = await callObject.join({ url: 'https://your-domain.daily.co/room-name' }); console.log('Joined meeting with participants:', participants); // { local: { session_id: 'abc123', user_name: 'John', local: true, ... }, 'xyz789': { ... } } } catch (error) { console.error('Failed to join:', error); } // Join with token and user settings const participants = await callObject.join({ url: 'https://your-domain.daily.co/private-room', token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', userName: 'Meeting Participant', userData: { role: 'presenter', company: 'Acme Inc' }, startVideoOff: false, startAudioOff: true, receiveSettings: { base: { video: { layer: 2 }, screenVideo: { layer: 2 } } } }); // Listen for join event callObject.on('joined-meeting', (event) => { console.log('Successfully joined:', event.participants); }); callObject.on('error', (event) => { console.error('Join failed:', event.errorMsg, event.error); }); ``` -------------------------------- ### Manage Waiting Participants in Daily.js Source: https://context7.com/daily-co/daily-js/llms.txt Use these methods to view, grant, deny, or batch update access for participants waiting in the lobby. Listen for events to react to changes in the waiting list. Non-owners can request access. ```javascript // Get all waiting participants (owner only) const waiting = callObject.waitingParticipants(); console.log('Waiting:', Object.values(waiting)); // [{ id: 'abc123', name: 'John Doe', awaitingAccess: { level: 'full' } }] ``` ```javascript // Grant access to a waiting participant await callObject.updateWaitingParticipant('waiting-participant-id', { grantRequestedAccess: true }); ``` ```javascript // Deny access (don't grant) await callObject.updateWaitingParticipant('waiting-participant-id', { grantRequestedAccess: false }); ``` ```javascript // Batch update multiple waiting participants await callObject.updateWaitingParticipants({ 'participant-id-1': { grantRequestedAccess: true }, 'participant-id-2': { grantRequestedAccess: true } }); ``` ```javascript // Listen for waiting participant events callObject.on('waiting-participant-added', (event) => { console.log('New participant waiting:', event.participant.name); }); ``` ```javascript callObject.on('waiting-participant-updated', (event) => { console.log('Waiting participant updated:', event.participant); }); ``` ```javascript callObject.on('waiting-participant-removed', (event) => { console.log('Waiting participant removed:', event.participant.name); }); ``` ```javascript // For non-owners: request access if in lobby const accessState = callObject.accessState(); if (accessState.access.level === 'lobby') { const result = await callObject.requestAccess({ access: { level: 'full' }, name: 'John Doe' }); console.log('Access granted:', result.granted); } ``` -------------------------------- ### Creating a Call Object Source: https://context7.com/daily-co/daily-js/llms.txt Creates an instance of the Daily call object for custom video call implementations without the pre-built UI. The `createCallObject()` factory method is the primary way to initialize a Daily call instance when building custom video experiences. It returns a DailyCall instance that you can configure with options before joining a meeting. ```APIDOC ## Creating a Call Object Creates an instance of the Daily call object for custom video call implementations without the pre-built UI. The `createCallObject()` factory method is the primary way to initialize a Daily call instance when building custom video experiences. It returns a DailyCall instance that you can configure with options before joining a meeting. ### Request Example ```javascript import Daily from '@daily-co/daily-js'; // Basic call object creation const callObject = Daily.createCallObject(); // Call object with configuration options const callObject = Daily.createCallObject({ url: 'https://your-domain.daily.co/room-name', token: 'your-meeting-token', userName: 'John Doe', startVideoOff: false, startAudioOff: false, dailyConfig: { micAudioMode: 'music', preferH264: true, } }); // Check browser support before creating const browserInfo = Daily.supportedBrowser(); if (browserInfo.supported) { const call = Daily.createCallObject(); } // browserInfo: { supported: true, mobile: false, name: 'Chrome', version: '120.0', supportsScreenShare: true, supportsVideoProcessing: true } ``` ### Response Example ```json // No direct response example for createCallObject, it returns a DailyCall instance. // Example of browserInfo response: // { supported: true, mobile: false, name: 'Chrome', version: '120.0', supportsScreenShare: true, supportsVideoProcessing: true } ``` ``` -------------------------------- ### Network Quality and Testing Source: https://context7.com/daily-co/daily-js/llms.txt APIs to monitor real-time network quality during calls and run pre-call tests to assess connection quality before joining. ```APIDOC ## Network Quality and Testing Monitor network conditions and run connection quality tests. Daily provides APIs to monitor real-time network quality during calls and run pre-call tests to assess connection quality before joining. ### Get Current Network Stats Retrieves the current network statistics for the ongoing call. **Method:** `getNetworkStats()` **Endpoint:** N/A (Instance method) **Returns:** - `networkState` (string) - The current network state ('good', 'warning', 'bad', 'unknown'). - `stats` (object) - An object containing detailed network statistics, including `recvBitsPerSecond`, `sendBitsPerSecond`, `videoRecvPacketLoss`, etc. ### Listen for Network Quality Changes Subscribes to events that indicate changes in network quality. **Method:** `on('network-quality-change', callback)` **Endpoint:** N/A (Instance method) **Callback Parameters:** - `event` (object) - `networkState` (string) - The new network state. - `networkStateReasons` (array) - Reasons for the network state change. - `quality` (object) - Detailed quality metrics. ### Run Pre-Call Quality Test Assesses the user's network connection quality before joining a call. **Method:** `testCallQuality()` **Endpoint:** N/A (Instance method) **Returns:** - `result` (string) - The test result ('good', 'warning', 'bad', 'failed'). - `data` (object) - Detailed test data, including `maxRoundTripTime`, `avgRoundTripTime`, `avgSendPacketLoss`, `avgAvailableOutgoingBitrate`. ### Stop Pre-Call Quality Test Stops an ongoing pre-call quality test. **Method:** `stopTestCallQuality()` **Endpoint:** N/A (Instance method) ### Test WebSocket Connectivity Tests the WebSocket connectivity to Daily's servers. **Method:** `testWebsocketConnectivity()` **Endpoint:** N/A (Instance method) **Returns:** - `result` (string) - The overall test result. - `passedRegions` (array) - List of regions where the test passed. - `failedRegions` (array) - List of regions where the test failed. ### CPU Load Monitoring Monitors the CPU load of the user's device. **Method:** `getCpuLoadStats()` **Endpoint:** N/A (Instance method) **Returns:** - `cpuLoadState` (string) - The current CPU load state ('low' or 'high'). - `cpuLoadStateReason` (string) - The reason for the current CPU load state. ### Listen for CPU Load Changes Subscribes to events that indicate changes in CPU load. **Method:** `on('cpu-load-change', callback)` **Endpoint:** N/A (Instance method) **Callback Parameters:** - `event` (object) - `cpuLoadState` (string) - The new CPU load state. ``` -------------------------------- ### Control Local Media Tracks Source: https://context7.com/daily-co/daily-js/llms.txt Manage the state of local audio and video, including muting/unmuting, and selecting input/output devices. Supports forcing track discard and cycling through cameras. ```javascript // Check current local media state const isVideoOn = callObject.localVideo(); const isAudioOn = callObject.localAudio(); const isScreenShareVideoOn = callObject.localScreenVideo(); const isScreenShareAudioOn = callObject.localScreenAudio(); ``` ```javascript // Toggle local audio/video callObject.setLocalAudio(false); // Mute microphone callObject.setLocalVideo(true); // Turn on camera ``` ```javascript // Mute and force discard the audio track callObject.setLocalAudio(false, { forceDiscardTrack: true }); ``` ```javascript // Set input devices await callObject.setInputDevicesAsync({ audioDeviceId: 'microphone-device-id', videoDeviceId: 'camera-device-id' }); ``` ```javascript // Set output device (speaker) await callObject.setOutputDeviceAsync({ outputDeviceId: 'speaker-device-id' }); ``` ```javascript // Get current device info const devices = await callObject.getInputDevices(); console.log('Camera:', devices.camera); console.log('Microphone:', devices.mic); console.log('Speaker:', devices.speaker); ``` ```javascript // Enumerate all available devices const { devices: allDevices } = await callObject.enumerateDevices(); const cameras = allDevices.filter(d => d.kind === 'videoinput'); const microphones = allDevices.filter(d => d.kind === 'audioinput'); const speakers = allDevices.filter(d => d.kind === 'audiooutput'); ``` ```javascript // Cycle through cameras const { device } = await callObject.cycleCamera(); console.log('Switched to camera:', device.label); ``` -------------------------------- ### Audio Level Monitoring Source: https://context7.com/daily-co/daily-js/llms.txt APIs for monitoring local and remote participant audio levels for real-time visualizations. ```APIDOC ## Audio Level Monitoring ### Description Monitor local and remote participant audio levels for visualizations. The audio level observer APIs provide real-time audio level data useful for building audio visualization features like speaking indicators. ### Local Audio Level Monitoring - `callObject.startLocalAudioLevelObserver(intervalMs)`: Start monitoring local audio level with a specified interval. - `callObject.isLocalAudioLevelObserverRunning()`: Check if the local audio level observer is running. - `callObject.getLocalAudioLevel()`: Get the current local audio level (0.0 to 1.0). - `callObject.stopLocalAudioLevelObserver()`: Stop the local audio level observer. ### Remote Audio Level Monitoring - `callObject.startRemoteParticipantsAudioLevelObserver(intervalMs)`: Start monitoring remote participants' audio levels with a specified interval. - `callObject.getRemoteParticipantsAudioLevel()`: Get the current audio levels for all remote participants. - `callObject.stopRemoteParticipantsAudioLevelObserver()`: Stop the remote audio level observer. ### Active Speaker Detection - `callObject.getActiveSpeaker()`: Get the current active speaker. ### Events - `local-audio-level`: Fired when the local audio level changes. - `remote-participants-audio-level`: Fired when remote participants' audio levels change. - `active-speaker-change`: Fired when the active speaker changes. ### Request Example (Start Local Observer) ```javascript await callObject.startLocalAudioLevelObserver(100); ``` ### Response Example (getLocalAudioLevel) ```json 0.75 ``` ### Response Example (getRemoteParticipantsAudioLevel) ```json { "session-id-1": 0.5, "session-id-2": 0.0 } ``` ### Response Example (getActiveSpeaker) ```json { "peerId": "participant-session-id" } ``` ``` -------------------------------- ### Create Embedded Daily Frame Source: https://context7.com/daily-co/daily-js/llms.txt Use `createFrame()` to embed Daily's pre-built video call interface as an iframe. Customize appearance, positioning, and tray buttons. The frame can be created in the document body or within a specific container element. ```javascript import Daily from '@daily-co/daily-js'; // Create frame in document body with default positioning const callFrame = Daily.createFrame({ url: 'https://your-domain.daily.co/room-name', showLeaveButton: true, showFullscreenButton: true, showParticipantsBar: true, theme: { colors: { accent: '#0066FF', accentText: '#FFFFFF', background: '#1A1A1A', mainAreaBg: '#121212', } } }); // Create frame in specific container element const container = document.getElementById('call-container'); const callFrame = Daily.createFrame(container, { url: 'https://your-domain.daily.co/room-name', iframeStyle: { width: '100%', height: '100%', border: 'none', }, customTrayButtons: { myButton: { iconPath: 'https://example.com/icon.svg', label: 'Custom Action', tooltip: 'Perform custom action' } } }); ```