### Audio Buffer Source Playback Example Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Demonstrates how to create a buffer source audio track and start processing it with specific playback options like looping and a defined start time. ```javascript const audioTrack = await AgoraRTC.createBufferSourceAudioTrack({ source: audioBuffer }); audioTrack.startProcessAudioBuffer(audioBuffer, { loop: true, startPlayTime: 5 // Start at 5 seconds }); ``` -------------------------------- ### Run Vue Quick Start Demo Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-vue/README.md Starts the Vue quick start demo development server using pnpm. ```bash pnpm run vue ``` -------------------------------- ### Run Development Server Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-react/README.md Start the React quick start demo in development mode. ```bash pnpm run dev ``` -------------------------------- ### Build Svelte Quick Start Demo Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-svelte/README.md Build the Svelte quick start demo using pnpm. ```bash pnpm run build:svelte ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/agora-plugin-vad-example/README.md Run this command to install all necessary packages for the project. ```sh npm install ``` -------------------------------- ### Live Streaming Transcoding Configuration Example Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Demonstrates how to configure live streaming with transcoding, including setting video properties, background color, watermark, and user layouts. This configuration is used when starting a live stream with the client SDK. ```javascript const config = { width: 1920, height: 1080, videoBitrate: 5000, videoFramerate: 30, backgroundColor: 0x000000, watermark: { url: 'https://example.com/watermark.png', x: 10, y: 10, width: 100, height: 50, zOrder: 1, alpha: 0.8 }, transcodingUsers: [ { uid: 'user1', x: 0, y: 0, width: 960, height: 1080, zOrder: 0, alpha: 1.0 } ] }; await client.startLiveStreaming('rtmp://your-endpoint', config); ``` -------------------------------- ### Build Vue Quick Start Demo Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-vue/README.md Builds the Vue quick start demo for production using pnpm. ```bash pnpm run build:vue ``` -------------------------------- ### Run Svelte Quick Start Demo Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-svelte/README.md Run the Svelte quick start demo using pnpm. ```bash pnpm run svelte ``` -------------------------------- ### Install Agora RTC Web SDK Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Install the SDK using npm, yarn, or pnpm. ```bash npm install agora-rtc-sdk-ng # or yarn add agora-rtc-sdk-ng # or pnpm add agora-rtc-sdk-ng ``` -------------------------------- ### Build for Production Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-react/README.md Build the React quick start demo for production deployment. ```bash pnpm run build ``` -------------------------------- ### Install Dependencies Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/quick-demo-svelte/README.md Install project dependencies using pnpm. ```bash pnpm i ``` -------------------------------- ### Install AgoraRTC SDK with npm Source: https://github.com/agoraio/agora-rtc-web/blob/main/README.md Install the AgoraRTC SDK using npm. This is the recommended way for most projects. ```bash # with npm npm i agora-rtc-sdk-ng ``` -------------------------------- ### Handle Remote User Publishing Media Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Subscribe to a remote user's audio or video track when they start publishing. This example shows how to play the video track if it's of type 'video'. ```javascript client.on('user-published', async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === 'video') { user.videoTrack.play('video-container'); } }); ``` -------------------------------- ### Install AgoraRTC SDK with npm Source: https://github.com/agoraio/agora-rtc-web/blob/main/packages/rtc-web-v4/README.md Install the AgoraRTC SDK using npm. This is the recommended method for Node.js projects. ```bash npm i agora-rtc-sdk-ng ``` -------------------------------- ### Create Agora RTC Client Examples Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Demonstrates how to create an Agora RTC client instance with different configurations for communication and live streaming modes. Includes examples for setting roles and audience latency levels. ```javascript // Communication mode with VP8 const client = AgoraRTC.createClient({ mode: 'rtc', codec: 'vp8' }); ``` ```javascript // Live streaming as host with H.264 const hostClient = AgoraRTC.createClient({ mode: 'live', codec: 'h264', role: 'host' }); ``` ```javascript // Live streaming as low-latency audience const audienceClient = AgoraRTC.createClient({ mode: 'live', codec: 'h264', role: 'audience', clientRoleOptions: { level: AudienceLatencyLevelType.AUDIENCE_LEVEL_LOW_LATENCY } }); ``` -------------------------------- ### Configuration Guide Documentation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/COMPLETION_REPORT.txt Guide detailing various configuration options for the Agora RTC Web SDK, including client, video, and audio configurations. ```APIDOC ## Configuration ### Client Configuration (ClientConfig) - **appId**: Your Agora Application ID. - **channelProfile**: The communication profile to use. - **codec**: The audio codec to use. - **mode**: The communication mode. ### Video Encoder Configuration - **resolution**: Video resolution. - **frameRate**: Video frame rate. - **bitrate**: Video bitrate. ### Audio Encoder Configuration - **sampleRate**: Audio sample rate. - **channels**: Number of audio channels. *(... and details on ScreenVideoTrackInitConfig, advanced settings like encryption, logging, etc.)* ``` -------------------------------- ### Install AgoraRTC SDK with pnpm Source: https://github.com/agoraio/agora-rtc-web/blob/main/README.md Install the AgoraRTC SDK using pnpm. This is an alternative package manager. ```bash # or with pnpm pnpm add agora-rtc-sdk-ng ``` -------------------------------- ### Handle Permission Denied Error Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/errors.md Recover from PERMISSION_DENIED errors when the user denies access to media devices. This example guides the user on enabling permissions in their browser settings. ```javascript try { const [audio, video] = await AgoraRTC.createMicrophoneAndCameraTracks(); } catch (error) { if (error.code === 'PERMISSION_DENIED') { console.error('User denied camera/microphone access'); // Show instructions to enable permissions // User must: Settings > Privacy > Camera/Microphone > Allow } } ``` -------------------------------- ### Install AgoraRTC SDK with yarn Source: https://github.com/agoraio/agora-rtc-web/blob/main/README.md Install the AgoraRTC SDK using yarn. This is another popular package manager. ```bash # or with yarn yarn add agora-rtc-sdk-ng ``` -------------------------------- ### Configuration Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Details on SDK setup and configuration options, including client configuration, video/audio track options, screen sharing setup, global settings like encryption and logging, and CDN streaming configuration. ```APIDOC ## Configuration ### Description This section covers the various configuration options available for setting up and customizing the Agora Web SDK. It details client-side configurations, options for audio and video tracks, settings for screen sharing, global parameters such as encryption and logging levels, and specific configurations for CDN live streaming. ### Configuration Areas - **Client Configuration**: Options for initializing the `IAgoraRTCClient`. - **Track Options**: Settings for local audio and video tracks (e.g., frame rate, resolution). - **Screen Sharing Setup**: Specific configurations for screen sharing functionality. - **Global Settings**: SDK-wide settings including encryption modes, logging verbosity, and server regions. - **CDN Live Streaming Configuration**: Parameters for configuring live streaming to CDNs. ### Related References - [IAgoraRTC](./api-reference/IAgoraRTC.md) - [IAgoraRTCClient](./api-reference/IAgoraRTCClient.md) ``` -------------------------------- ### Run Development Server Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/agora-plugin-vad-example/README.md Use this command to start the development server with hot-reloading enabled. ```sh npm run dev ``` -------------------------------- ### IBufferSourceAudioTrack.startProcessAudioBuffer Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Starts processing an audio buffer with optional playback options. ```APIDOC ## startProcessAudioBuffer ### Description Starts processing an audio buffer with playback options. ### Method ```typescript startProcessAudioBuffer(source: AudioBuffer, options?: AudioSourceOptions): void ``` ### Parameters #### Path Parameters - **source** (AudioBuffer) - Required - PCM audio buffer - **options** (AudioSourceOptions) - Optional - { cycle?, loop?, startPlayTime? } ``` -------------------------------- ### startChannelMediaRelay Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Starts relaying streams to other channels. Requires a configuration object specifying source and destination channels. ```APIDOC ## startChannelMediaRelay ### Description Starts relaying streams to other channels. Requires a configuration object specifying source and destination channels. ### Method Promise ### Endpoint IAgoraRTCClient.startChannelMediaRelay(config: IChannelMediaRelayConfiguration) ### Parameters #### Request Body - **config** (IChannelMediaRelayConfiguration) - Required - Relay configuration with source and destination channels ### Request Example ```javascript const relayConfig = AgoraRTC.createChannelMediaRelayConfiguration(); relayConfig.setSrcChannelInfo({ channelName: 'src-channel', uid: 0, token: 'src-token' }); relayConfig.addDestChannelInfo({ channelName: 'dest-channel-1', uid: 123, token: 'dest-token-1' }); relayConfig.addDestChannelInfo({ channelName: 'dest-channel-2', uid: 456, token: 'dest-token-2' }); await client.startChannelMediaRelay(relayConfig); ``` ``` -------------------------------- ### Control Buffer Source Audio Track Playback Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Demonstrates how to control the playback of a buffer source audio track, including starting playback and processing audio buffers with looping and specific start times. ```javascript // Playback control bgMusic.play(); bgMusic.startProcessAudioBuffer(audioBuffer, { loop: true, // Loop infinitely startPlayTime: 10 // Start at 10 seconds }); ``` -------------------------------- ### Create Microphone Audio Track Examples Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Demonstrates creating microphone audio tracks with various configurations, including default, speech-optimized, high-quality stereo, custom settings, and low-bandwidth options. ```javascript // Default music quality const audioTrack = await AgoraRTC.createMicrophoneAudioTrack(); // Speech optimized const speechTrack = await AgoraRTC.createMicrophoneAudioTrack({ encoderConfig: 'speech_standard' }); // High quality stereo const stereoTrack = await AgoraRTC.createMicrophoneAudioTrack({ encoderConfig: 'high_quality_stereo' }); // Custom configuration const customAudio = await AgoraRTC.createMicrophoneAudioTrack({ encoderConfig: { sampleRate: 48000, stereo: false, bitrate: 64 }, audioProcessingConfig: { AEC: true, // Echo cancellation AGC: true, // Automatic gain control ANS: true // Noise suppression } }); // Low-bandwidth configuration const lowBandwidth = await AgoraRTC.createMicrophoneAudioTrack({ encoderConfig: 'speech_low_quality' }); ``` -------------------------------- ### Start Content Inspection Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Starts content moderation for published video and audio streams. Requires a configuration object to define inspection parameters. ```typescript startContentInspect(config: InspectConfiguration): Promise ``` -------------------------------- ### Implement a Complete Grid Layout for Remote Users Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCRemoteUser.md A comprehensive example demonstrating how to manage a dynamic grid layout for displaying remote video streams. It handles adding, removing, and playing video for users, and updates the grid layout based on the number of participants. ```javascript class VideoGrid { constructor() { this.users = new Map(); // uid -> { user, videoDiv } this.container = document.getElementById('video-grid'); } addUser(user) { if (!this.users.has(user.uid)) { const videoDiv = document.createElement('div'); videoDiv.className = 'video-tile'; videoDiv.id = `video-${user.uid}`; this.container.appendChild(videoDiv); this.users.set(user.uid, { user, videoDiv }); this.updateLayout(); } } removeUser(uid) { if (this.users.has(uid)) { const { videoDiv } = this.users.get(uid); videoDiv.remove(); this.users.delete(uid); this.updateLayout(); } } playVideo(user) { if (this.users.has(user.uid)) { const { videoDiv } = this.users.get(user.uid); user.videoTrack?.play(videoDiv); } } stopVideo(uid) { if (this.users.has(uid)) { const { user } = this.users.get(uid); user.videoTrack?.stop(); } } updateLayout() { const count = this.users.size; const cols = Math.ceil(Math.sqrt(count)); this.container.style.gridTemplateColumns = `repeat(${cols}, 1fr)`; } } // Usage const grid = new VideoGrid(); client.on('user-joined', (user) => { grid.addUser(user); }); client.on('user-published', async (user, mediaType) => { if (mediaType === 'video') { await client.subscribe(user, 'video'); grid.playVideo(user); } else if (mediaType === 'audio') { await client.subscribe(user, 'audio'); user.audioTrack.play(); } }); client.on('user-unpublished', async (user, mediaType) => { if (mediaType === 'video') { grid.stopVideo(user.uid); } }); client.on('user-left', (user) => { grid.removeUser(user.uid); }); ``` -------------------------------- ### IMicrophoneAudioTrack.getSettings Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Gets the current settings of the microphone audio track, such as sample rate, channel count, and echo cancellation. ```APIDOC ## getSettings ### Description Gets current microphone settings (sampleRate, channelCount, echoCancellation, etc.). ### Method ```typescript getSettings(): MediaTrackSettings ``` ``` -------------------------------- ### IBufferSourceAudioTrack.play Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Starts playing the audio from an audio buffer source. ```APIDOC ## play ### Description Starts playing the audio file. ### Method ```typescript play(): void ``` ``` -------------------------------- ### startLiveStreaming Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Pushes streams to a CDN address. This method allows you to start live streaming to a specified RTMP URL, with optional transcoding configurations. ```APIDOC ## startLiveStreaming ### Description Pushes streams to a CDN address. This method allows you to start live streaming to a specified RTMP URL, with optional transcoding configurations. ### Method startLiveStreaming ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **url** (string) - Required - RTMP URL for the CDN endpoint - **transcodingConfig** (LiveStreamingTranscodingConfig) - Optional - Transcoding settings (resolution, bitrate, layout, watermarks) ### Request Example ```typescript // Example usage: // client.startLiveStreaming('rtmp://example.com/live/stream', { resolution: '1920x1080', bitrate: 4000 }); ``` ### Response #### Success Response (void) This method returns a void promise upon successful initiation of the live stream. #### Response Example ```json // No response body for success ``` ``` -------------------------------- ### startContentInspect Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Starts content moderation for published video/audio. This feature helps in detecting and managing inappropriate content. ```APIDOC ## startContentInspect ### Description Starts content moderation for published video/audio. This feature helps in detecting and managing inappropriate content. ### Method startContentInspect ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **config** (InspectConfiguration) - Required - Configuration object for content inspection. ### Request Example ```typescript // Example usage: // client.startContentInspect({ scene: ' போர்ட்ரைட்', autoScene: true }); ``` ### Response #### Success Response (void) This method returns a void promise upon successful initiation of content inspection. #### Response Example ```json // No response body for success ``` ``` -------------------------------- ### Full Agora RTC Web Example Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Demonstrates a complete Agora RTC Web application flow, including client initialization, track creation, joining a channel, publishing, subscribing to remote users, playing media, adjusting video quality, and cleanup. ```javascript // Initialize client const client = AgoraRTC.createClient({ mode: 'rtc', codec: 'vp8' }); // Create tracks const [audioTrack, videoTrack] = await AgoraRTC.createMicrophoneAndCameraTracks(); // Join and publish await client.join('APP_ID', 'channel', 'token', 'userId'); await client.publish([audioTrack, videoTrack]); // Play local video videoTrack.play('local-video'); // Handle remote users client.on('user-published', async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === 'video') { user.videoTrack.play(`remote-video-${user.uid}`); } else if (mediaType === 'audio') { user.audioTrack.play(); user.audioTrack.setVolume(80); } }); // Adjust video quality await videoTrack.setEncoderConfiguration({ width: 640, height: 480, frameRate: 24, bitrateMax: 1500 }); // Cleanup await client.unpublish(); videoTrack.stop(); audioTrack.stop(); await client.leave(); ``` -------------------------------- ### Start Processing Audio Buffer Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Initiates the processing of an AudioBuffer with optional playback configurations like looping and start time. ```typescript startProcessAudioBuffer(source: AudioBuffer, options?: AudioSourceOptions): void ``` -------------------------------- ### AudioSourceOptions Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Provides options for configuring the playback of audio buffer sources, including looping and start times. ```APIDOC ## AudioSourceOptions ### Description Playback options for audio buffer sources. ### Properties - **cycle** (number) - Optional - Number of times to loop - **loop** (boolean) - Optional - Loop infinitely - **startPlayTime** (number) - Optional - Start position (seconds) ### Usage Example ```javascript const audioTrack = await AgoraRTC.createBufferSourceAudioTrack({ source: audioBuffer }); audioTrack.startProcessAudioBuffer(audioBuffer, { loop: true, startPlayTime: 5 // Start at 5 seconds }); ``` ``` -------------------------------- ### Start Live Streaming to CDN Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Pushes streams to a CDN address using RTMP. Requires a valid RTMP URL. Transcoding configuration is optional. ```typescript startLiveStreaming(url: string, transcodingConfig?: LiveStreamingTranscodingConfig): Promise ``` -------------------------------- ### Play Audio File Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Starts playback of an audio file associated with a buffer source audio track. ```typescript play(): void ``` -------------------------------- ### Errors Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Comprehensive guide to error handling, including a reference to the error class, a complete catalog of error codes, patterns for error recovery, and debugging examples. ```APIDOC ## Errors ### Description This document provides a detailed guide to error handling within the Agora Web SDK. It includes a reference to the SDK's error class, a comprehensive catalog of all error codes (over 100), recommended patterns for recovering from errors, and practical debugging examples to help resolve issues. ### Error Handling Components - **Error Class Reference**: Details on the structure and properties of error objects. - **Error Code Catalog**: An exhaustive list of all possible error codes and their meanings. - **Error Recovery Patterns**: Strategies and best practices for handling and recovering from common errors. - **Debugging Examples**: Practical code snippets demonstrating how to debug and troubleshoot errors. ### Related References - [Types](./types.md) ``` -------------------------------- ### Set Low Stream Parameter Usage Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Example of how to set low-bitrate stream parameters using the client API. This is useful for optimizing bandwidth usage for remote streams. ```javascript await client.setLowStreamParameter({ width: 320, height: 240, frameRate: 15, bitrate: 500 }); ``` -------------------------------- ### AudioSourceOptions Interface Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Specifies playback options for audio buffer sources, including how many times to loop, whether to loop infinitely, and the start time for playback. ```typescript interface AudioSourceOptions { cycle?: number; loop?: boolean; startPlayTime?: number; } ``` -------------------------------- ### Handle Constraint Not Satisfied Error Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/errors.md Manage CONSTRAINT_NOT_SATISFIED errors when a media device cannot meet the specified constraints. This example shows falling back to a lower resolution. ```javascript try { const track = await AgoraRTC.createCameraVideoTrack({ encoderConfig: { width: 7680, height: 4320 } // Unrealistic resolution }); } catch (error) { if (error.code === 'CONSTRAINT_NOT_SATISFIED') { console.error('Device does not support requested settings'); // Fall back to lower quality const track = await AgoraRTC.createCameraVideoTrack({ encoderConfig: '720p_auto' }); } } ``` -------------------------------- ### Get Local Playback Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves playback statistics for a remote video track, such as resolution, frame rate, and bytes received. No specific setup is required beyond having a remote video track instance. ```typescript getLocalPlaybackStatistics(): RemoteVideoTrackStats ``` -------------------------------- ### Handle Enumerate Devices Failed Error Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/errors.md Catch ENUMERATE_DEVICES_FAILED errors when the SDK fails to list available media devices. This example suggests granting permissions as a potential solution. ```javascript try { const devices = await AgoraRTC.getDevices(); } catch (error) { if (error.code === 'ENUMERATE_DEVICES_FAILED') { console.error('Cannot enumerate devices. Grant permissions first.'); } } ``` -------------------------------- ### Main Entry Point Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Provides factory methods for creating clients and tracks, device enumeration, configuration options, and system checks. ```APIDOC ## Main Entry Point ### Description Provides factory methods for creating clients and tracks, device enumeration, configuration options, and system checks. ### Factory Methods - **AgoraRTC.createClient(config)**: Creates an RTC client instance. - **AgoraRTC.createMicrophoneAudioTrack(config?)**: Creates a local microphone audio track. - **AgoraRTC.createCameraVideoTrack(config?)**: Creates a local camera video track. - **AgoraRTC.createMicrophoneAndCameraTracks(audioConfig?, videoConfig?)**: Creates both microphone and camera tracks. - **AgoraRTC.createScreenVideoTrack(config, withAudio?)**: Creates a screen video track. - **AgoraRTC.createBufferSourceAudioTrack(config)**: Creates an audio track from a buffer source. ### Device Methods - **AgoraRTC.getDevices()**: Retrieves all available media devices. - **AgoraRTC.getMicrophones()**: Retrieves available microphone devices. - **AgoraRTC.getCameras()**: Retrieves available camera devices. - **AgoraRTC.getPlaybackDevices()**: Retrieves available playback devices. ### Configuration - **AgoraRTC.setArea(area)**: Sets the network area for the SDK. - **AgoraRTC.setEncryptionConfig(config)**: Configures encryption for the connection. - **AgoraRTC.setAppId(appId)**: Sets the App ID for the SDK. - **AgoraRTC.setLogLevel(level)**: Sets the logging level. - **AgoraRTC.enableLogUpload()**: Enables log upload. ### Checks - **AgoraRTC.checkSystemRequirements()**: Checks if the system meets the requirements. - **AgoraRTC.getSupportedCodec()**: Gets the supported codec. ``` -------------------------------- ### Basic Error Handling for Device Creation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/errors.md Handles common errors like permission denial, device not found, or unsupported constraints when creating audio and video tracks. Ensure necessary imports are present. ```javascript import AgoraRTC from 'agora-rtc-sdk-ng'; try { const audioTrack = await AgoraRTC.createMicrophoneAudioTrack(); const videoTrack = await AgoraRTC.createCameraVideoTrack(); await client.publish([audioTrack, videoTrack]); } catch (error) { if (error.code === 'PERMISSION_DENIED') { console.error('Camera/microphone permission denied by user'); } else if (error.code === 'DEVICE_NOT_FOUND') { console.error('Camera or microphone not found'); } else if (error.code === 'CONSTRAINT_NOT_SATISFIED') { console.error('Device does not support requested settings'); } else { console.error(`Error: ${error.code} - ${error.message}`); } } ``` -------------------------------- ### Start Channel Media Relay Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Starts relaying streams to other channels. Requires a configuration object specifying source and destination channels. ```typescript startChannelMediaRelay(config: IChannelMediaRelayConfiguration): Promise ``` ```javascript const relayConfig = AgoraRTC.createChannelMediaRelayConfiguration(); relayConfig.setSrcChannelInfo({ channelName: 'src-channel', uid: 0, token: 'src-token' }); relayConfig.addDestChannelInfo({ channelName: 'dest-channel-1', uid: 123, token: 'dest-token-1' }); relayConfig.addDestChannelInfo({ channelName: 'dest-channel-2', uid: 456, token: 'dest-token-2' }); await client.startChannelMediaRelay(relayConfig); ``` -------------------------------- ### Build for Production Source: https://github.com/agoraio/agora-rtc-web/blob/main/projects/agora-plugin-vad-example/README.md Execute this command to type-check, compile, and minify the project for production deployment. ```sh npm run build ``` -------------------------------- ### Electron Screen Capture Usage Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Additional-Interfaces.md Demonstrates how to retrieve available screen sources and create a screen video track in an Electron environment using AgoraRTC. Ensure Electron is supported. ```javascript const sources = await AgoraRTC.getElectronScreenSources('screen'); sources.forEach(source => { console.log(`${source.id}: ${source.name}`); }); const screenTrack = await AgoraRTC.createScreenVideoTrack({ screenSourceType: 'screen' }); ``` -------------------------------- ### AgoraRTC Factory and Device Methods Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Explore factory methods for creating clients and tracks, as well as device enumeration methods. Configuration options for the SDK are also shown. ```javascript import AgoraRTC from 'agora-rtc-sdk-ng'; // Factory methods AgoraRTC.createClient(config) AgoraRTC.createMicrophoneAudioTrack(config?) AgoraRTC.createCameraVideoTrack(config?) AgoraRTC.createMicrophoneAndCameraTracks(audioConfig?, videoConfig?) AgoraRTC.createScreenVideoTrack(config, withAudio?) AgoraRTC.createBufferSourceAudioTrack(config) // Device methods AgoraRTC.getDevices() AgoraRTC.getMicrophones() AgoraRTC.getCameras() AgoraRTC.getPlaybackDevices() // Configuration AgoraRTC.setArea(area) AgoraRTC.setEncryptionConfig(config) AgoraRTC.setAppId(appId) AgoraRTC.setLogLevel(level) AgoraRTC.enableLogUpload() // Checks AgoraRTC.checkSystemRequirements() AgoraRTC.getSupportedCodec() ``` -------------------------------- ### Enumerate All Media Devices Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Use `getDevices` to list all available media input and output devices. Optionally skip the permission request by setting `skipPermissionCheck` to true. ```javascript const devices = await AgoraRTC.getDevices(); devices.forEach(device => { console.log(`${device.kind}: ${device.label} (${device.deviceId})`); }); ``` -------------------------------- ### ICameraVideoTrack.getCameraId Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Gets the current camera device ID for the local video track. ```APIDOC ## getCameraId ### Description Gets the current camera device ID. ### Method GET ### Endpoint `/tracks/camera/id` ### Parameters None ### Response #### Success Response (200) - **cameraId** (string) - The ID of the current camera device. ``` -------------------------------- ### getDevices Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Enumerates all available media input and output devices. It can optionally skip the permission request. ```APIDOC ## getDevices ### Description Enumerates all available media input and output devices. This method can optionally skip the permission request. ### Method Signature ```typescript getDevices(skipPermissionCheck?: boolean): Promise ``` ### Parameters #### Query Parameters - **skipPermissionCheck** (boolean) - Optional - If true, skips permission request ### Returns - Promise resolving to an array of `MediaDeviceInfo` objects. ### Example ```javascript const devices = await AgoraRTC.getDevices(); devices.forEach(device => { console.log(`${device.kind}: ${device.label} (${device.deviceId})`); }); ``` ``` -------------------------------- ### Get Camera Device ID Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves the unique identifier for the currently active camera device. ```typescript getCameraId(): string ``` -------------------------------- ### createMicrophoneAndCameraTracks Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Creates both audio and video tracks simultaneously for improved efficiency compared to separate calls. ```APIDOC ## createMicrophoneAndCameraTracks ### Description Creates both audio and video tracks in a single call (more efficient than separate calls). ### Method Signature ```typescript createMicrophoneAndCameraTracks( audioConfig?: MicrophoneAudioTrackInitConfig, videoConfig?: CameraVideoTrackInitConfig ): Promise<[IMicrophoneAudioTrack, ICameraVideoTrack]> ``` ### Parameters #### Optional Parameters - **audioConfig** (MicrophoneAudioTrackInitConfig) - Description: Audio configuration - **videoConfig** (CameraVideoTrackInitConfig) - Description: Video configuration ### Returns Promise resolving to tuple `[IMicrophoneAudioTrack, ICameraVideoTrack]`. ### Example ```javascript const [audioTrack, videoTrack] = await AgoraRTC.createMicrophoneAndCameraTracks( { encoderConfig: 'music_standard' }, { encoderConfig: '720p_auto' } ); await client.publish([audioTrack, videoTrack]); ``` ``` -------------------------------- ### Get Microphone Settings Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves the current configuration of the microphone, such as sample rate and echo cancellation. ```typescript getSettings(): MediaTrackSettings ``` -------------------------------- ### Handle Camera Permission Denied or Device Not Found Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/types.md Use a try-catch block to handle potential errors when creating a camera video track. Check for specific error codes like PERMISSION_DENIED or DEVICE_NOT_FOUND to provide user-friendly messages. ```javascript import AgoraRTC from 'agora-rtc-sdk-ng'; try { const track = await AgoraRTC.createCameraVideoTrack(); } catch (error) { if (error.code === AgoraRTC.AgoraRTCErrorCode.PERMISSION_DENIED) { console.error('Camera permission denied'); } else if (error.code === AgoraRTC.AgoraRTCErrorCode.DEVICE_NOT_FOUND) { console.error('No camera found'); } } ``` -------------------------------- ### IAgoraRTC Interface Documentation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/COMPLETION_REPORT.txt Documentation for the IAgoraRTC interface, which serves as the SDK entry point and includes over 30 methods for core functionalities. ```APIDOC ## IAgoraRTC ### Description This interface is the primary entry point for the Agora RTC Web SDK, providing access to core functionalities and methods for managing real-time communication. ### Methods - **createInstance()**: Creates an instance of the IAgoraRTC interface. - **join(options)**: Joins a channel. - **leave()**: Leaves the current channel. - **destroy()**: Destroys the SDK instance. *(... and 30+ other methods)* ``` -------------------------------- ### Create Camera Video Track with Preset Configuration Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Creates a camera video track using a predefined quality preset. This is suitable for standard video quality requirements and prioritizes detail. ```javascript // Preset configuration const videoTrack = await AgoraRTC.createCameraVideoTrack({ encoderConfig: '720p_auto', facingMode: 'user', optimizationMode: 'detail' // Prioritize quality }); ``` -------------------------------- ### Create Buffer Source Audio Track from File Input Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Create an audio track from a local file selected by the user via a file input element. The `source` property should be the File object obtained from the input. ```javascript // From file input const fileInput = document.getElementById('audioFile'); const userAudio = await AgoraRTC.createBufferSourceAudioTrack({ source: fileInput.files[0], encoderConfig: 'music_standard' }); ``` -------------------------------- ### Get Channel Mode Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Determine the current channel mode, which can be either 'rtc' for communication or 'live' for interactive streaming. ```typescript readonly mode: SDK_MODE ``` -------------------------------- ### Create Media Relay Configuration Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Use `createChannelMediaRelayConfiguration` to generate an empty configuration object for setting up media relay between channels. ```typescript createChannelMediaRelayConfiguration(): IChannelMediaRelayConfiguration ``` -------------------------------- ### Get Audio Processor Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves the current audio processor associated with the track, allowing for extension-based audio processing. ```typescript getProcessor(): IBaseProcessor | null ``` -------------------------------- ### startImageModeration Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Starts image moderation for shared screens or uploaded images. This feature helps in detecting inappropriate visual content. ```APIDOC ## startImageModeration ### Description Starts image moderation for shared screens or uploaded images. This feature helps in detecting inappropriate visual content. ### Method startImageModeration ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **config** (any) - Optional - Configuration for image moderation. The exact structure depends on the implementation. ### Request Example ```typescript // Example usage: // client.startImageModeration({ type: 'all' }); ``` ### Response #### Success Response (void) This method returns a void promise upon successful initiation of image moderation. #### Response Example ```json // No response body for success ``` ``` -------------------------------- ### IAgoraRTC Interface Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/INDEX.md The SDK entry point interface, providing factory methods for clients and tracks, device enumeration, track creation, global configuration, codec compatibility checks, extension registration, and device event handlers. ```APIDOC ## IAgoraRTC ### Description Provides factory methods for creating AgoraRTCClient instances and various types of local tracks (audio, video, screen, file, custom). It also handles device enumeration, global SDK configuration (like region, logging, encryption), codec compatibility checks, extension registration, and manages device event handlers. ### Interface IAgoraRTC ### Methods - `createClient(options)`: Creates an IAgoraRTCClient instance. - `getDevices()`: Enumerates available audio and video devices. - `createMicrophoneAudioTrack()`: Creates a local microphone audio track. - `createCameraVideoTrack()`: Creates a local camera video track. - `createScreenVideoTrack()`: Creates a local screen video track. - `setGlobalOptions(options)`: Configures global SDK settings. - `registerExtension(name, extension)`: Registers a custom extension. ### Events - `device-enumerate-error`: Fired when an error occurs during device enumeration. - `enumerate-devices`: Fired when devices are enumerated. ``` -------------------------------- ### Start Image Moderation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Initiates image moderation for shared screens or uploaded images. An optional configuration object can be provided. ```typescript startImageModeration(config?: any): Promise ``` -------------------------------- ### Create Buffer Source Audio Track from URL Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Use this snippet to create an audio track from a remote URL. Ensure `cacheOnlineFile` is set to true if you want to cache the downloaded file for repeated use. ```javascript // From URL const bgMusic = await AgoraRTC.createBufferSourceAudioTrack({ source: 'https://cdn.example.com/background-music.mp3', cacheOnlineFile: true, encoderConfig: 'high_quality' }); ``` -------------------------------- ### Get Channel Name Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Retrieve the name of the channel the client is currently connected to. This property is undefined until the client has joined a channel. ```typescript readonly channelName?: string ``` -------------------------------- ### Get User ID Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Obtain the unique identifier for the local user. This ID can be a number or a string and is only available after successfully joining a channel. ```typescript readonly uid?: UID ``` -------------------------------- ### Basic Video Call Implementation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md This snippet demonstrates the essential steps for establishing a basic video call using the Agora RTC Web SDK, including client creation, track management, joining a channel, publishing, and subscribing to streams. ```javascript import AgoraRTC from 'agora-rtc-sdk-ng'; // Step 1: Create client const client = AgoraRTC.createClient({ mode: 'rtc', codec: 'vp8' }); // Step 2: Create tracks const [audioTrack, videoTrack] = await AgoraRTC.createMicrophoneAndCameraTracks(); // Step 3: Join channel await client.join('APP_ID', 'channel-name', 'token', 'user-id'); // Step 4: Publish local tracks await client.publish([audioTrack, videoTrack]); // Step 5: Play local video videoTrack.play('local-video'); // Step 6: Subscribe to remote users client.on('user-published', async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === 'video') { user.videoTrack.play(`remote-video-${user.uid}`); } else { user.audioTrack.play(); } }); // Step 7: Clean up client.on('user-left', (user) => { user.videoTrack?.stop(); user.audioTrack?.stop(); }); // Leave channel await client.leave(); ``` -------------------------------- ### Create Camera Video Track with Constraint-Based Configuration Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/configuration.md Creates a camera video track using browser-based constraints for width, height, and frame rate. This allows the browser to optimize settings within the specified ranges. ```javascript // Constraint-based configuration (let browser optimize) const constrainedTrack = await AgoraRTC.createCameraVideoTrack({ encoderConfig: { width: { min: 320, ideal: 640, max: 1280 }, height: { min: 240, ideal: 480, max: 720 }, frameRate: { ideal: 30, max: 60 } } }); ``` -------------------------------- ### Get Supported Codecs Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Retrieves the audio and video codecs supported by the current browser. This is useful for determining which codecs can be used for media transmission. ```javascript AgoraRTC.getSupportedCodec().then(result => { console.log(`Video codecs: ${result.video.join(',')}`); console.log(`Audio codecs: ${result.audio.join(',')}`); }); ``` -------------------------------- ### getPlaybackDevices Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Enumerates all available audio output devices (speakers/headphones). It can optionally skip the permission request. ```APIDOC ## getPlaybackDevices ### Description Enumerates available audio output devices (speakers/headphones). This method can optionally skip the permission request. ### Method Signature ```typescript getPlaybackDevices(skipPermissionCheck?: boolean): Promise ``` ### Parameters #### Query Parameters - **skipPermissionCheck** (boolean) - Optional - If true, skips permission request ### Returns - Promise resolving to an array of playback device `MediaDeviceInfo` objects. ``` -------------------------------- ### Get Remote Audio Playback Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves statistics about the playback of a remote audio track, including bytes received and codec information. ```typescript getLocalPlaybackStatistics(): RemoteAudioTrackStats ``` -------------------------------- ### Get Underlying MediaStreamTrack Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Retrieves the native MediaStreamTrack object from the Web APIs, which can be useful for advanced use cases or integration with other WebRTC functionalities. ```typescript getMediaStreamTrack(): MediaStreamTrack ``` -------------------------------- ### Publish Local Tracks Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Use the `publish` method to send local audio and/or video tracks to the channel. You can publish a single track or an array of tracks. Note that only one video track can be published at a time, and in 'live' mode, only hosts can publish. ```javascript // Publish single track const audioTrack = await AgoraRTC.createMicrophoneAudioTrack(); await client.publish(audioTrack); // Publish multiple tracks const [audioTrack, videoTrack] = await AgoraRTC.createMicrophoneAndCameraTracks(); await client.publish([audioTrack, videoTrack]); // Publish additional audio to existing video const backgroundMusic = await AgoraRTC.createBufferSourceAudioTrack({ source: 'https://example.com/music.mp3' }); await client.publish(backgroundMusic); // Now publishing 2 audio tracks + 1 video ``` -------------------------------- ### Handle Device Not Found Error Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/errors.md Catch DEVICE_NOT_FOUND errors when a required media device is unavailable. This example shows how to inform the user if a microphone is not detected. ```javascript try { const audioTrack = await AgoraRTC.createMicrophoneAudioTrack(); } catch (error) { if (error.code === 'DEVICE_NOT_FOUND') { console.error('Microphone not found'); // Show user message to connect microphone } } ``` -------------------------------- ### Create Screen Video Track Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Creates a video track for screen sharing, with an option to include audio. Configuration includes screen capture settings and audio sharing preference. ```javascript // Screen sharing without audio const screenTrack = await AgoraRTC.createScreenVideoTrack({ encoderConfig: { width: 1280, height: 720, frameRate: 15 } }); await client.publish(screenTrack); // Screen sharing with audio const [screenTrack, screenAudio] = await AgoraRTC.createScreenVideoTrack( { encoderConfig: { width: 1280, height: 720 } }, 'enable' ); ``` -------------------------------- ### Get Remote Video Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Retrieves statistics for subscribed remote video tracks. This method provides insights into the quality of received video from other users. ```typescript getRemoteVideoStats(): RemoteVideoTrackStats ``` -------------------------------- ### Project File Structure Overview Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/INDEX.md This markdown snippet illustrates the file structure of the Agora RTC Web SDK project, indicating the purpose of each file and directory. ```markdown /workspace/home/output/ ├── README.md (Overview and quick start) ├── INDEX.md (This file) ├── types.md (Type definitions) ├── configuration.md (Setup guide) ├── errors.md (Error reference) └── api-reference/ ├── IAgoraRTC.md (SDK entry point) ├── IAgoraRTCClient.md (Channel management) ├── Tracks.md (Audio/video tracks) ├── IAgoraRTCRemoteUser.md (Remote users) └── Additional-Interfaces.md (Supporting types) ``` -------------------------------- ### Get Remote Audio Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Retrieves statistics for subscribed remote audio tracks. This method provides insights into the quality of received audio from other users. ```typescript getRemoteAudioStats(): RemoteAudioTrackStats ``` -------------------------------- ### Get Local Audio Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Retrieves statistics for the published local audio track. This includes audio level, bytes sent, codec information, and more. ```typescript getLocalAudioStats(): LocalAudioTrackStats ``` -------------------------------- ### IAgoraRTCClient Interface Documentation Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/COMPLETION_REPORT.txt Documentation for the IAgoraRTCClient interface, responsible for channel management and offering over 25 methods for controlling the client's behavior within a channel. ```APIDOC ## IAgoraRTCClient ### Description The IAgoraRTCClient interface manages channel operations, including publishing and subscribing to media streams, and handling remote user interactions. ### Methods - **publish(localTrack)**: Publishes a local audio or video track to the channel. - **subscribe(user, mediaType)**: Subscribes to a remote user's audio or video stream. - **getStats()**: Retrieves statistics for the current connection. - **setClientRole(role)**: Sets the client role (e.g., host, audience). *(... and 25+ other methods)* ``` -------------------------------- ### Get Local Tracks Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Access an array of local audio and video tracks that have been published by this client. This array is automatically updated when tracks are published or unpublished. ```typescript readonly localTracks: ILocalTrack[] ``` -------------------------------- ### autoplay-failed Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Triggered when autoplay is blocked by the browser, necessitating user interaction to resume audio playback. This event handler is useful for guiding users to enable audio. ```APIDOC ## autoplay-failed ### Description This event is triggered when the browser blocks autoplay, which prevents audio playback without explicit user interaction. It signals that a user action is required to resume audio. ### Event Name autoplay-failed ### Example ```javascript AgoraRTC.on('autoplay-failed', () => { // Show button to user to resume audio const btn = document.createElement('button'); btn.innerText = 'Click to unmute'; document.body.appendChild(btn); }); ``` ``` -------------------------------- ### AgoraRTC Client Core Methods Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/README.md Reference for core client methods including joining and leaving channels, publishing and subscribing to tracks, and managing client roles. ```javascript const client = AgoraRTC.createClient(config); // Core client.join(appid, channel, token, uid?) client.leave() client.publish(tracks) client.unpublish(tracks?) client.subscribe(user, mediaType) client.unsubscribe(user, mediaType?) // Management client.setClientRole(role, options?) client.setRemoteVideoStreamType(user, streamType) // Statistics client.getRTCStats() client.getLocalAudioStats() client.getLocalVideoStats() client.getRemoteAudioStats() client.getRemoteVideoStats() // Relay & Streaming client.startChannelMediaRelay(config) client.stopChannelMediaRelay() client.startLiveStreaming(url, transcodingConfig?) client.stopLiveStreaming(url) // Properties client.connectionState client.remoteUsers client.localTracks client.uid client.channelName ``` -------------------------------- ### IBufferSourceAudioTrack.on('source-state-change') Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/Tracks.md Listens for changes in the audio buffer source playback state. ```APIDOC ## on('source-state-change') ### Description Listens for changes in the audio buffer source playback state. ### Method ```javascript track.on('source-state-change', (state) => { // state: 'playing' | 'paused' | 'stopped' }); ``` ``` -------------------------------- ### Check System Requirements Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Verifies if the current browser meets the minimum system requirements for the Agora Web SDK. If the browser is not compatible, it logs an error. ```javascript if (!AgoraRTC.checkSystemRequirements()) { console.error('Browser is not supported'); } ``` -------------------------------- ### Get Local Video Statistics Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Retrieves statistics for the published local video track. This includes bytes sent, codec information, frame rate, resolution, and more. ```typescript getLocalVideoStats(): LocalVideoTrackStats ``` -------------------------------- ### checkSystemRequirements Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTC.md Checks if the current browser meets the SDK's system requirements. Returns a boolean indicating compatibility. ```APIDOC ## checkSystemRequirements ### Description Checks whether the current browser is compatible with the SDK. ### Method `checkSystemRequirements` ### Parameters None ### Request Example ```javascript if (!AgoraRTC.checkSystemRequirements()) { console.error('Browser is not supported'); } ``` ### Response #### Success Response - **boolean** - `true` if compatible, `false` otherwise. ``` -------------------------------- ### Get Connection State Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md Access the current connection state of the SDK with the Agora server. This property indicates whether the client is disconnected, connecting, connected, or reconnecting. ```typescript readonly connectionState: ConnectionState ``` -------------------------------- ### user-published Event Source: https://github.com/agoraio/agora-rtc-web/blob/main/_autodocs/api-reference/IAgoraRTCClient.md This event is triggered when a remote user starts publishing their audio or video track. It allows the client to subscribe to and play the newly available media stream. ```APIDOC ## user-published ### Description Triggered when remote user publishes audio/video track. ### Event Handler Signature ```javascript client.on('user-published', async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === 'video') { user.videoTrack.play('video-container'); } }); ``` ### Event Parameters - **user** (object) - The user who published the media. - **mediaType** (string) - The type of media published ('audio' or 'video'). ```