Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RtcEngine

RtcEngine is the main class of the Agora SDK.

Hierarchy

  • RtcEngine

Implements

  • RtcEngineInterface

Index

Methods

Methods

addListener

  • addListener<EventType>(event: EventType, listener: RtcEngineEvents[EventType]): Subscription
  • Adds the RtcEngineEvents handler.

    After setting the RtcEngineEvents handler, you can listen for RtcEngine events and receive the statistics of the corresponding RtcEngine instance.

    Type parameters

    Parameters

    • event: EventType

      The event type.

    • listener: RtcEngineEvents[EventType]

      The RtcEngineEvents handler.

    Returns Subscription

addPublishStreamUrl

  • addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise<void>
  • Publishes the local stream to a specified CDN streaming URL.

    deprecated

    This method is deprecated as of v3.6.2. See Release Notes for an alternative solution.

    After calling this method, you can push media streams in RTMP or RTMPS protocol to the CDN.

    This SDK triggers the RtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN.

    Note

    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Push Streams to CDN.
    • This method applies to LiveBroadcasting only.
    • Ensure that the user joins a channel before calling this method.
    • This method adds only one CDN streaming URL each time it is called.
    • Agora supports pushing media streams in RTMPS protocol to the CDN only when you enable transcoding.

    Parameters

    • url: string

      The CDN streaming URL in the RTMP or RTMPS format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.

    • transcodingEnabled: boolean

      Whether to enable transcoding. If you set this parameter as true, ensure that you call setLiveTranscoding before this method.

      • true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple hosts in CDN live.
      • false: Disable transcoding.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): Invalid parameter, usually because the URL address is null or the string length is 0.
      • 7(NotInitialized): You have not initialized RtcEngine when publishing the stream.

addVideoWatermark

  • addVideoWatermark(watermarkUrl: string, options: WatermarkOptions): Promise<void>
  • Adds a watermark image to the local video.

    This method adds a PNG watermark image to the local video stream in a live interactive streaming. Once the watermark image is added, all the audience in the channel (CDN audience included), and the recording device can see and capture it.

    Agora supports adding only one watermark image onto the local video, and the newly-added watermark image replaces the previous one. The watermark position depends on the settings in the setVideoEncoderConfiguration method:

    • If the orientation mode of the encoding video is FixedLandscape, or the landscape mode in Adaptative, the watermark uses the landscape orientation.

    • If the orientation mode of the encoding video is FixedPortrait, or the portrait mode in Adaptative, the watermark uses the portrait orientation.

    • When setting the watermark position, the region must be less than the dimensions set in the setVideoEncoderConfiguration method. Otherwise, the watermark image will be cropped.

    Note

    • Ensure that you have called enableVideo to enable the video module before calling this method.

    • If you only want to add a watermark image to the local video for the audience in the CDN live interactive streaming channel to see and capture, you can call this method or the setLiveTranscoding method.

    • This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray.

    • If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings.

    • If you have enabled the local video preview by calling startPreview, you can use the visibleInPreview member in the WatermarkOptions class to set whether the watermark is visible in preview.

    • If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer.

    Parameters

    • watermarkUrl: string

      The local file path of the watermark image to be added.

      • On Android: Agora supports using a URI address, an absolute path, or a path that starts with /assets/ to access a local file. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead.
      • On iOS: This method supports adding a watermark image from the local file path. If the watermark image to be added is in the project file, you need to change the image’s Type from PNG image to Data in the Xcode property; otherwise, the Agora Native SDK cannot recognize the image.
    • options: WatermarkOptions

      The options of the watermark image to be added.

    Returns Promise<void>

adjustAudioMixingPlayoutVolume

  • adjustAudioMixingPlayoutVolume(volume: number): Promise<void>
  • Adjusts the volume of audio mixing for local playback.

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • volume: number

      Audio mixing volume for local playback. The value ranges between 0 and 100 (default).

    Returns Promise<void>

adjustAudioMixingPublishVolume

  • adjustAudioMixingPublishVolume(volume: number): Promise<void>
  • Adjusts the volume of audio mixing for publishing (sending to other users).

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • volume: number

      Audio mixing volume for publishing. The value ranges between 0 and 100 (default).

    Returns Promise<void>

adjustAudioMixingVolume

  • adjustAudioMixingVolume(volume: number): Promise<void>
  • Adjusts the volume of audio mixing.

    Note

    • Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    • Calling this method does not affect the volume of the audio effect file playback invoked by the playEffect method.

    Parameters

    • volume: number

      Audio mixing volume. The value ranges between 0 and 100 (default).

    Returns Promise<void>

adjustPlaybackSignalVolume

  • adjustPlaybackSignalVolume(volume: number): Promise<void>
  • Adjusts the playback volume of all remote users.

    Note

    • This method adjusts the playback volume which is mixed volume of all remote users.
    • To mute the local audio playback, call both this method and adjustAudioMixingVolume, and set volume as 0.

    Parameters

    • volume: number

      The playback volume.The value ranges between 0 and 400, including the following:

      • 0: Mute.
      • 100: (Default) Original volume.
      • 400: Four times the original volume with signal-clipping protection.

    Returns Promise<void>

adjustRecordingSignalVolume

  • adjustRecordingSignalVolume(volume: number): Promise<void>
  • Adjusts the volume of the signal captured by the microphone

    Parameters

    • volume: number

      The volume of the signal captured by the microphone.The value ranges between 0 and 400, including the following:

      • 0: Mute.
      • 100: (Default) Original volume.
      • 400: Four times the original volume with signal-clipping protection.

    Returns Promise<void>

adjustUserPlaybackSignalVolume

  • adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise<void>
  • Adjusts the playback volume of a specified remote user.

    You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user.

    Note

    • Call this method after joining a channel.
    • The playback volume here refers to the mixed volume of a specified remote user.
    • This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user.

    Parameters

    • uid: number

      ID of the remote user.

    • volume: number

      The playback volume of the specified remote user. The value ranges from 0 to 100:

      • 0: Mute.
      • 100: The original volume.

    Returns Promise<void>

clearVideoWatermarks

  • clearVideoWatermarks(): Promise<void>
  • Removes the watermark image from the video stream added by addVideoWatermark.

    Returns Promise<void>

complain

  • complain(callId: string, description: string): Promise<void>
  • Allows a user to complain about the call quality after a call ends.

    Parameters

    • callId: string

      ID of the call retrieved from the getCallId method.

    • description: string

      (Optional) The description of the complaint. The string length must be less than 800 bytes.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 3(NotReady): The SDK fails to be initialized. You can try re-initializing the SDK.

configRhythmPlayer

  • Configures the virtual metronome.

    since

    v3.4.2

    After calling startRhythmPlayer, you can call this method to reconfigure the virtual metronome.

    Note After reconfiguring the virtual metronome, the SDK plays the specified files from the beginning and controls the beat duration according to the value you set in beatsPerMinute. If the file duration exceeds the beat duration, the SDK only plays the audio within the beat duration.

    Parameters

    Returns Promise<void>

createDataStream

  • createDataStream(reliable: boolean, ordered: boolean): Promise<number>
  • Creates a data stream.

    deprecated

    This method is deprecated from v3.3.1. Use the createDataStreamWithConfig method instead.

    Ensure that you call this method after joining a channel.

    Each user can create up to five data streams during the lifecycle of the RtcEngine.

    Note

    Set both the reliable and ordered parameters to true or false. Do not set one as true and the other as false.

    Parameters

    • reliable: boolean

      Sets whether the recipients are guaranteed to receive the data stream from the sender within five seconds:

      • true: The recipients receive the data from the sender within five seconds. If the recipient does not receive the data within five seconds, the SDK triggers the StreamMessageError callback and returns an error code.

      • false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream.

    • ordered: boolean

      Sets whether the recipients receive the data stream in the sent order:

      • true: The recipients receive the data in the sent order.
      • false: The recipients do not receive the data in the sent order.

    Returns Promise<number>

    • Returns the stream ID, if the method call is successful.
    • Error codes: Failure. The error code is related to the integer displayed in Error Codes.

createDataStreamWithConfig

  • Creates a data stream.

    since

    v3.3.1.

    Each user can create up to five data streams in a single channel.

    This method does not support data reliability. If the receiver receives a data packet five seconds or more after it was sent, the SDK directly discards the data.

    Parameters

    Returns Promise<number>

    • Returns the stream ID if you successfully create the data stream.
    • An error code if the method call fails.

destroy

  • destroy(): Promise<void>
  • Destroys the RtcEngine instance and releases all resources used by the Agora SDK.

    Use this method for apps in which users occasionally make voice or video calls. When users do not make calls, you can free up resources for other operations. Once you call this method to destroy the created RtcEngine instance, you cannot use any method or callback in the SDK any more. If you want to use the real-time communication functions again, you must call create to create a new RtcEngine instance.

    Note

    • Because destroy is a synchronous method and the app cannot move on to another task until the execution completes, Agora suggests calling this method in a sub-thread to avoid congestion in the main thread. Besides, you cannot call destroy in any method or callback of the SDK. Otherwise, the SDK cannot release the resources occupied by the RtcEngine instance until the callbacks return results, which may result in a deadlock.
    • If you want to create a new RtcEngine instance after destroying the current one, ensure that you wait till the destroy method completes executing.

    Returns Promise<void>

disableAudio

  • disableAudio(): Promise<void>
  • Disables the audio module.

    Note

    • This method affects the audio module and can be called after calling leaveChannel. You can call this method either before or after joining a channel.

    • This method enables/disables the audio module and takes some time to take effect. We recommend using the following API methods to control the audio module separately:

    • enableLocalAudio: Whether to enable the microphone to create the local audio stream.

    • muteLocalAudioStream: Whether to publish the local audio stream.

    • muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream.

    • muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams.

    Returns Promise<void>

disableLastmileTest

  • disableLastmileTest(): Promise<void>
  • Disables the network connection quality test.

    Returns Promise<void>

disableVideo

  • disableVideo(): Promise<void>
  • Disables the video module.

    You can call this method before joining a channel or during a call:

    • If you call this method before joining a channel, the service starts in audio mode.
    • If you call this method during a video call, the video mode switches to the audio mode.

    A successful call of this method triggers the UserEnableVideo(false) callback on the remote client.

    To enable the video mode, call enableVideo.

    Note

    • This method affects the internal engine and can be called after calling leaveChannel. You can call this method either before or after joining a channel.

    • This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately:

    • enableLocalVideo: Whether to enable the camera to create the local video stream.

    • muteLocalVideoStream: Whether to publish the local video stream.

    • muteRemoteVideoStream: Whether to subscribe to and play the remote video stream.

    • muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams.

    Returns Promise<void>

enableAudio

  • enableAudio(): Promise<void>
  • Enables the audio module.

    The audio module is enabled by default.

    Note

    • This method affects the audio module and can be called after calling leaveChannel. You can call this method either before or after joining a channel.

    • This method enables/disables the audio module and takes some time to take effect. We recommend using the following API methods to control the audio module separately:

    • enableLocalAudio: Whether to enable the microphone to create the local audio stream.

    • muteLocalAudioStream: Whether to publish the local audio stream.

    • muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream.

    • muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams.

    Returns Promise<void>

enableAudioVolumeIndication

  • enableAudioVolumeIndication(interval: number, smooth: number, report_vad: boolean): Promise<void>
  • Enables the AudioVolumeIndication callback at a set time interval to report on which users are speaking and the speakers' volume.

    Once this method is enabled, the SDK returns the volume indication in the AudioVolumeIndication callback at the set time interval, regardless of whether any user is speaking in the channel.

    Parameters

    • interval: number

      Sets the time interval between two consecutive volume indications:

      • ≤ 0: Disables the volume indication.
      • > 0: Time interval (ms) between two consecutive volume indications. Agora recommends setting interval ≥ 200 ms.
    • smooth: number

      The smoothing factor sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The greater the value, the more sensitive the indicator. The recommended value is 3.

    • report_vad: boolean
      • true: Enable the voice activity detection of the local user. Once it is enabled, the vad parameter of the AudioVolumeIndication callback reports the voice activity status of the local user.
      • false: (Default) Disable the voice activity detection of the local user. Once it is disabled, the vad parameter of the AudioVolumeIndication callback does not report the voice activity status of the local user, except for scenarios where the engine automatically detects the voice activity of the local user.

    Returns Promise<void>

enableDeepLearningDenoise

  • enableDeepLearningDenoise(enabled: boolean): Promise<void>
  • Enables or disables deep-learning noise reduction.

    since

    v3.3.1.

    The SDK enables traditional noise reduction mode by default to reduce most of the stationary background noise. If you need to reduce most of the non-stationary background noise, Agora recommends enabling deep-learning noise reduction as follows:

      1. Integrate the following file under the libs folder to your project:
      • Android: libagora_ai_denoise_extension.so
      • iOS: AgoraAIDenoiseExtension.xcframework
      1. Call enableDeepLearningDenoise(true).

    Deep-learning noise reduction requires high-performance devices.

    After successfully enabling deep-learning noise reduction, if the SDK detects that the device performance is not sufficient, it automatically disables deep-learning noise reduction and enables traditional noise reduction.

    If you call enableDeepLearningDenoise(false) or the SDK automatically disables deep-learning noise reduction in the channel, when you need to re-enable deep-learning noise reduction, you need to call leaveChannel first, and then call enableDeepLearningDenoise(true).

    Note

    • This method dynamically loads libagora_ai_denoise_extension.so on Android or AgoraAIDenoiseExtension.xcframework on iOS, so Agora recommends calling this method before joining a channel.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.

    Parameters

    • enabled: boolean

      Sets whether to enable deep-learning noise reduction.

      • true: Enables deep-learning noise reduction.
      • false: Disables deep-learning noise reduction.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 157(ModuleNotFound): The library for enabling deep-learning noise reduction is not integrated.

enableDualStreamMode

  • enableDualStreamMode(enabled: boolean): Promise<void>
  • Enables/Disables the dual video stream mode.

    If dual-stream mode is enabled, the receiver can choose to receive the high stream (high-resolution high-bitrate video stream) or low stream (low-resolution low-bitrate video stream) video.

    Parameters

    • enabled: boolean

      Sets the stream mode:

      • true: Dual-stream mode.
      • false: (Default) Single-stream mode.

    Returns Promise<void>

enableEncryption

  • Enables/Disables the built-in encryption.

    since

    v3.1.2.

    In scenarios requiring high security, Agora recommends calling enableEncryption to enable the built-in encryption before joining a channel.

    After a user leaves the channel, the SDK automatically disables the built-in encryption. To re-enable the built-in encryption, call this method before the user joins the channel again.

    As of v3.4.5, Agora recommends using either the AES128GCM2 or AES256GCM2 encryption mode, both of which support adding a salt and are more secure. For details, see Media Stream Encryption.

    Warning All users in the same channel must use the same encryption mode, encryption key, and salt; otherwise, users cannot communicate with each other.

    Note

    • If you enable the built-in encryption, you cannot use the RTMP or RTMPS streaming function.
    • To enhance security, Agora recommends using a new key and salt every time you enable the media stream encryption.

    Parameters

    • enabled: boolean

      Whether to enable the built-in encryption.

      • true: Enable the built-in encryption.
      • false: Disable the built-in encryption.
    • config: EncryptionConfig

      Configurations of built-in encryption schemas. See EncryptionConfig.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): An invalid parameter is used. Set the parameter with a valid value.
      • 4(NotSupported): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library.
      • 7(NotInitialized): The SDK is not initialized. Initialize the RtcEngine instance before calling this method.

enableFaceDetection

  • enableFaceDetection(enable: boolean): Promise<void>
  • Enables/Disables face detection for the local user.

    Once face detection is enabled, the SDK triggers the FacePositionChanged callback to report the face information of the local user, which includes the following aspects:

    • The width and height of the local video.
    • The position of the human face in the local video.
    • The distance between the human face and the device screen.

    Note You can call this method either before or after joining a channel.

    Parameters

    • enable: boolean

      Determines whether to enable the face detection function for the local user:

      • true: Enable face detection.
      • false: (Default) Disable face detection.

    Returns Promise<void>

enableInEarMonitoring

  • enableInEarMonitoring(enabled: boolean): Promise<void>
  • Enables in-ear monitoring.

    Parameters

    • enabled: boolean

      Sets whether to enable/disable in-ear monitoring:

      • true: Enable.
      • false: (Default) Disable.

    Returns Promise<void>

enableLastmileTest

  • enableLastmileTest(): Promise<void>
  • Enables the network connection quality test.

    This method tests the quality of the users' network connections and is disabled by default.

    Before users join a channel or before an audience switches to a host, call this method to check the uplink network quality. This method consumes additional network traffic, which may affect the communication quality. Call disableLastmileTest to disable this test after receiving the LastmileQuality callback, and before the user joins a channel or switches the user role.

    Note

    • Do not use this method with the startLastmileProbeTest method.

    • Do not call any other methods before receiving the LastmileQuality callback. Otherwise, the callback may be interrupted by other methods and may not execute.

    • In the LiveBroadcasting profile, a host should not call this method after joining a channel.

    • If you call this method to test the last-mile quality, the SDK consumes the bandwidth of a video stream, whose bitrate corresponds to the bitrate you set in the setVideoEncoderConfiguration method.

    • After you join the channel, whether you have called disableLastmileTest or not, the SDK automatically stops consuming the bandwidth.

    Returns Promise<void>

enableLocalAudio

  • enableLocalAudio(enabled: boolean): Promise<void>
  • Enables/Disables the local audio capture.

    The audio function is enabled by default. This method disables/re-enables the local audio function, that is, to stop or restart local audio capture and processing.

    This method does not affect receiving the remote audio streams, and enableLocalAudio(false) is applicable to scenarios where the user wants to receive remote audio streams without sending any audio stream to other users in the channel.

    Once the local audio function is disabled or re-enabled, the SDK triggers the LocalAudioStateChanged callback, which reports Stopped or Recording. The SDK triggers the LocalAudioStateChanged callback once the local audio function is disabled or re-enabled.

    Note

    This method is different from the muteLocalAudioStream method:

    • enableLocalAudio: Disables/Re-enables the local audio capture and processing. If you disable or re-enable local audio recording using enableLocalAudio, the local user may hear a pause in the remote audio playback.

    • muteLocalAudioStream: Stops/Continues sending the local audio streams.

    Parameters

    • enabled: boolean

      Sets whether to disable/re-enable the local audio function:

      • true: (Default) Re-enable the local audio function, that is, to start local audio capture and processing.
      • false: Disable the local audio function, that is, to stop local audio capture and processing.

    Returns Promise<void>

enableLocalVideo

  • enableLocalVideo(enabled: boolean): Promise<void>
  • Disables/Re-enables the local video capture.

    This method disables or re-enables the local video capturer, and does not affect receiving the remote video stream.

    After you call enableVideo, the local video capturer is enabled by default. You can call enableLocalVideo(false) to disable the local video capturer. If you want to re-enable it, call enableLocalVideo(true).

    After the local video capturer is successfully disabled or re-enabled, the SDK triggers the UserEnableLocalVideo callback on the remote client.

    Note

    • This method affects the internal engine and can be called after calling leaveChannel.

    Parameters

    • enabled: boolean

      Sets whether to disable/re-enable the local video, including the capturer, renderer, and sender:

      • true: (Default) Re-enable the local video.
      • false: Disable the local video. Once the local video is disabled, the remote users can no longer receive the video stream of this user, while this user can still receive the video streams of other remote users. When you set enabled as false, this method does not require a local camera.

    Returns Promise<void>

enableLocalVoicePitchCallback

  • enableLocalVoicePitchCallback(interval: number): Promise<void>
  • Enables reporting the voice pitch of the local user.

    since

    v3.7.0

    This method enables the SDK to regularly report the voice pitch of the local user. After the local audio capture is enabled, and you call this method, the SDK triggers the LocalVoicePitchInHz callback at the time interval set in this method.

    Note You can call this method either before or after joining a channel.

    Parameters

    • interval: number

      Sets the time interval at which the SDK triggers the LocalVoicePitchInHz callback:

      • ≤ 0: Disables the LocalVoicePitchInHz callback.
      • > 0: The time interval (ms) at which the SDK triggers the LocalVoicePitchInHz callback. The value must be greater than or equal to 10. If the value is less than 10, the SDK automatically changes it to 10.

    Returns Promise<void>

enableRemoteSuperResolution

  • enableRemoteSuperResolution(uid: number, enabled: boolean): Promise<void>
  • Enables/Disables the super-resolution algorithm for a remote user's video stream.

    since

    v3.5.2

    This feature effectively boosts the resolution of a remote user's video seen by the local user. If the original resolution of a remote user's video is a × b, the local user's device can render the remote video at a resolution of 2a × 2b after you enable this feature.

    After calling this method, the SDK triggers the UserSuperResolutionEnabled callback to report whether you have successfully enabled super resolution.

    Warning The original resolution of the remote user's video cannot exceed a certain range. If the local user use super resolution on Android, the original resolution of the remote user's video cannot exceed 640 × 360 pixels; if the local user use super resolution on iOS, the original resolution of the remote user's video cannot exceed 640 × 480 pixels.

    If you exceed these limitations, the SDK triggers the {@link IRtcEngineEventHandler#onWarning onWarning} callback and returns the corresponding warning codes:

    • SuperResolutionStreamOverLimitation(1610): The original resolution of the remote user's video is beyond the range where super resolution can be applied.
    • SuperResolutionUserCountOverLimitation(1611): Super resolution is already being used to boost another remote user's video.
    • SuperResolutionDeviceNotSupported(1612): The device does not support using super resolution.

    Note Because this method has certain system performance requirements, Agora recommends that you use the following devices or better:

    • Android:
      • VIVO: V1821A, NEX S, 1914A, 1916A, 1962A, 1824BA, X60, X60 Pro
      • OPPO: PCCM00, Find X3
      • OnePlus: A6000
      • Xiaomi: Mi 8, Mi 9, Mi 10, Mi 11, MIX3, Redmi K20 Pro
      • SAMSUNG: SM-G9600, SM-G9650, SM-N9600, SM-G9708, SM-G960U, SM-G9750, S20, S21
      • HUAWEI: SEA-AL00, ELE-AL00, VOG-AL00, YAL-AL10, HMA-AL00, EVR-AN00, nova 4, nova 5 Pro, nova 6 5G, nova 7 5G, Mate 30, Mate 30 Pro, Mate 40, Mate 40 Pro, P40 P40 Pro, HUAWEI MediaPad M6, MatePad 10.8
    • iOS (iOS 12.0 or later):
      • iPhone XR
      • iPhone XS
      • iPhone XS Max
      • iPhone 11
      • iPhone 11 Pro
      • iPhone 11 Pro Max
      • iPhone 12
      • iPhone 12 mini
      • iPhone 12 Pro
      • iPhone 12 Pro Max
      • iPhone 12 SE (2nd generation)
      • iPad Pro 11-inch (3rd generation)
      • iPad Pro 12.9-inch (3rd generation)
      • iPad Air (3rd generation)
      • iPad Air (4th generation)

    Parameters

    • uid: number

      The user ID of the remote user.

    • enabled: boolean

      Determines whether to enable super resolution for the remote user's video:

      • true: Enable super resolution.
      • false: Do not enable super resolution.

    Returns Promise<void>

enableSoundPositionIndication

  • enableSoundPositionIndication(enabled: boolean): Promise<void>
  • Enables/Disables stereo panning for remote users.

    Ensure that you call this method before calling joinChannel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling setRemoteVoicePosition.

    Parameters

    • enabled: boolean

      Sets whether to enable stereo panning for remote users:

      • true: Enable stereo panning.
      • false: Disable stereo panning.

    Returns Promise<void>

enableVideo

  • enableVideo(): Promise<void>
  • Enables the video module.

    You can call this method either before joining a channel or during a call:

    • If you call this method before joining a channel, the service starts in the video mode.
    • If you call this method during an audio call, the audio mode switches to the video mode.

    A successful call of this method triggers the UserEnableVideo(true) callback on the remote client.

    To disable the video, call the disableVideo method.

    Note

    • This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel.

    • This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately:

    • enableLocalVideo: Whether to enable the camera to create the local video stream.

    • muteLocalVideoStream: Whether to publish the local video stream.

    • muteRemoteVideoStream: Whether to subscribe to and play the remote video stream.

    • muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams.

    Returns Promise<void>

enableVirtualBackground

  • Enables/Disables the virtual background function.

    since

    v3.5.0.3

    After enabling the virtual background function, you can replace the original background image of the local user with a custom background image. After the replacement, all users in the channel can see the custom background image. You can find out from the [VirtualBackgroundSourceEnabled]{@link RtcChannelEvents.VirtualBackgroundSourceEnabled} callback whether the virtual background is successfully enabled or the cause of any errors.

    Note

    • Call this method after enableVideo.
    • This functions requires a high-performance device. Agora recommends that you use this function on the following devices:
      • Android: Devices with the following chips:
        • Snapdragon 700 series 750G and later
        • Snapdragon 800 series 835 and later
        • Dimensity 700 series 720 and later
        • Kirin 800 series 810 and later
        • Kirin 900 series 980 and later
      • iOS: Devices with an A9 chip and better, as follows:
        • iPhone 6S and later
        • iPad Air (3rd generation) and later
        • iPad (5th generation) and later
        • iPad Pro (1st generation) and later
        • iPad mini (5th generation) and later
    • Agora recommends that you use this function in scenarios that meet the following conditions:
      • A high-definition camera device is used, and the environment is uniformly lit.
      • The captured video image is uncluttered, the user's portrait is half-length and largely unobstructed, and the background is a single color that differs from the color of the user's clothing.
    • For versions earlier than v3.6.2, the virtual background feature does not support video in the Texture format.

    Parameters

    • enabled: boolean

      Sets whether to enable the virtual background:

      • true: Enable.
      • false: Disable.
    • backgroundSource: VirtualBackgroundSource

      The custom background image. See VirtualBackgroundSource. Note: To adapt the resolution of the custom background image to the resolution of the SDK capturing video, the SDK scales and crops the custom background image while ensuring that the content of the custom background image is not distorted.

    Returns Promise<void>

enableWebSdkInteroperability

  • enableWebSdkInteroperability(enabled: boolean): Promise<void>
  • Enables interoperability with the Agora Web SDK (LiveBroadcasting only).

    deprecated

    This method is deprecated. The Agora Native SDK automatically enables interoperability with the Web SDK, so you no longer need to call this method.

    If the channel has Web SDK users, ensure that you call this method, or the video of the Native user will be a black screen for the Web user. Use this method when the channel profile is LiveBroadcasting. Interoperability with the Agora Web SDK is enabled by default when the channel profile is Communication.

    Parameters

    • enabled: boolean

      Sets whether to enable/disable interoperability with the Agora Web SDK:

      • true: Enable.
      • false: (Default) Disable.

    Returns Promise<void>

getAudioFileInfo

  • getAudioFileInfo(filePath: string): Promise<void>
  • Gets the information of a specified audio file.

    since

    v3.5.2

    After calling this method successfully, the SDK triggers the RequestAudioFileInfo callback to report the information of an audio file, such as audio duration. You can call this method multiple times to get the information of multiple audio files.

    Note

    Parameters

    • filePath: string

      The file path, including the filename extensions.

      • Android: To access an online file, Agora supports using a URL address; to access a local file, Agora supports using a URI address, an absolute path, or a path that starts with /assets/. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: content://com.android.providers.media.documents/document/audio%3A14441.
      • iOS: The absolute path or URL address (including the filename extensions) of the music file. For example: /var/mobile/Containers/Data/audio.mp4.

    Returns Promise<void>

getAudioMixingCurrentPosition

  • getAudioMixingCurrentPosition(): Promise<number>
  • Gets the playback position (ms) of the music file.

    Note

    • Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.
    • If you need to call getAudioMixingCurrentPosition multiple times, ensure that the call interval is longer than 500 ms.

    Returns Promise<number>

    • The current playback position of the audio mixing, if the method call is successful.
    • An error code if the method call fails.

getAudioMixingDuration

  • getAudioMixingDuration(filePath?: undefined | string): Promise<number>
  • Gets the duration (ms) of the music file.

    deprecated

    This method is deprecated as of v3.5.1. Use getAudioFileInfo instead.

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • Optional filePath: undefined | string

      @since v3.4.2 The file path, including the filename extensions.

      • On Android: Agora supports using a URI address, an absolute path, or a path that starts with /assets/. Note: You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: "content://com.android.providers.media.documents/document/audio%3A14441". Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. For more information, see Media Formats Supported by Android.
      • On iOS: Agora supports using an absolute path. For example: "/var/mobile/Containers/Data/audio.mp4". Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. For more information, see Best Practices for iOS Audio.

    Returns Promise<number>

    • The audio mixing duration, if the method call is successful.
    • An error code if the method call fails.

getAudioMixingPlayoutVolume

  • getAudioMixingPlayoutVolume(): Promise<number>
  • Gets the audio mixing volume for local playback.

    This method helps troubleshoot audio volume related issues.

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Returns Promise<number>

    • The audio mixing volume for local playback, if the method call is successful. The value range is [0,100].
    • An error code if the method call fails.

getAudioMixingPublishVolume

  • getAudioMixingPublishVolume(): Promise<number>
  • Gets the audio mixing volume for publishing.

    This method helps troubleshoot audio volume related issues.

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Returns Promise<number>

    • The audio mixing volume for publishing, if the method call is successful. The value range is [0,100].
    • An error code if the method call fails.

getAudioTrackCount

  • getAudioTrackCount(): Promise<number>

getCallId

  • getCallId(): Promise<string>
  • Gets the current call ID.

    When a user joins a channel on a client, a call ID is generated to identify the call from the client. Feedback methods, such as rate and complain, must be called after the call ends to submit feedback to the SDK.

    The rate and complain methods require the callId parameter retrieved from the getCallId method during a call. callId is passed as an argument into the rate and complain methods after the call ends.

    Returns Promise<string>

    Current call ID.

getCameraMaxZoomFactor

  • getCameraMaxZoomFactor(): Promise<number>
  • Gets the maximum zoom ratio supported by the camera.

    This method applies to Android only.

    Returns Promise<number>

    The maximum camera zoom factor if the method call succeeds.

getConnectionState

  • Gets the connection state of the SDK.

    Returns Promise<ConnectionStateType>

    The connection state of the SDK if the method call succeeds.

getEffectCurrentPosition

  • getEffectCurrentPosition(soundId: number): Promise<number>
  • Gets the playback position of the audio effect file.

    since

    v3.4.2

    Note Call this method after playEffect.

    Parameters

    • soundId: number

      Audio effect ID. Ensure that this parameter is set to the same value as in playEffect.

    Returns Promise<number>

    • The playback position (ms) of the specified audio effect file, if the method call succeeds.
    • An error code if the method call fails.

getEffectDuration

  • getEffectDuration(filePath: string): Promise<number>
  • Gets the duration of the audio effect file.

    since

    v3.4.2

    Note

    Parameters

    • filePath: string

      The file path, including the filename extensions.

      • On Android: Agora supports using a URI address, an absolute path, or a path that starts with /assets/. Note: You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: "content://com.android.providers.media.documents/document/audio%3A14441".
      • On iOS: Agora supports using an absolute path. For example: "/var/mobile/Containers/Data/audio.mp4".

    Returns Promise<number>

    • The total duration (ms) of the specified audio effect file, if the method call succeeds.
    • An error code if the method call fails.

getEffectsVolume

  • getEffectsVolume(): Promise<number>
  • Gets the volume of the audio effects.

    The value ranges between 0.0 and 100.0.

    Returns Promise<number>

    • Returns the volume, if the method call is successful.
    • Error codes: Failure.

getNativeHandle

  • getNativeHandle(): Promise<number>
  • Gets the native handle of the SDK engine.

    This interface is used to retrieve the native C++ handle of the SDK engine used in special scenarios, such as registering the audio and video frame observer.

    Returns Promise<number>

    The native handle of the SDK engine if the method call succeeds.

getUserInfoByUid

  • getUserInfoByUid(uid: number): Promise<UserInfo>
  • Gets the user information by passing in the user ID.

    After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the UserInfoUpdated callback on the local client.

    After receiving the UserInfoUpdated callback, you can call this method to get the user ID of the remote user from the UserInfo object by passing in the user account.

    Parameters

    • uid: number

      The user ID of the user. Ensure that you set this parameter.

    Returns Promise<UserInfo>

    The user information if the method call succeeds.

getUserInfoByUserAccount

  • getUserInfoByUserAccount(userAccount: string): Promise<UserInfo>
  • Gets the user information by passing in the user account.

    After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the UserInfoUpdated callback on the local client.

    After receiving the UserInfoUpdated callback, you can call this method to get the user ID of the remote user from the UserInfo object by passing in the user account.

    Parameters

    • userAccount: string

      The user account of the user. Ensure that you set this parameter.

    Returns Promise<UserInfo>

    The user information if the method call succeeds.

isCameraAutoFocusFaceModeSupported

  • isCameraAutoFocusFaceModeSupported(): Promise<boolean>
  • Checks whether the camera auto-face focus function is supported.

    Returns Promise<boolean>

    • true: The device supports the camera auto-face focus function.
    • false: The device does not support the camera auto-face focus function.

isCameraExposurePositionSupported

  • isCameraExposurePositionSupported(): Promise<boolean>
  • Checks whether the camera exposure function is supported.

    Returns Promise<boolean>

    • true: The device supports the camera exposure function.
    • false: The device does not support the camera exposure function.

isCameraFocusSupported

  • isCameraFocusSupported(): Promise<boolean>
  • Checks whether the camera manual focus function is supported.

    Returns Promise<boolean>

    • true: The device supports the camera manual focus function.
    • false: The device does not support the camera manual focus function.

isCameraTorchSupported

  • isCameraTorchSupported(): Promise<boolean>
  • Checks whether the device supports enabling the flash.

    The SDK uses the front camera by default, so if you call isCameraTorchSupported directly, you can find out from the return value whether the device supports enabling the flash when using the front camera. If you want to check whether the device supports enabling the flash when using the rear camera, call switchCamera to switch the camera used by the SDK to the rear camera, and then call isCameraTorchSupported.

    Note Call this method after the camera is started.

    Returns Promise<boolean>

    • true: The device supports enabling the flash.
    • false: The device does not support enabling the flash.

isCameraZoomSupported

  • isCameraZoomSupported(): Promise<boolean>
  • Checks whether the camera zoom function is supported.

    Returns Promise<boolean>

    • true: The device supports the camera zoom function.
    • false: The device does not support the camera zoom function.

isSpeakerphoneEnabled

  • isSpeakerphoneEnabled(): Promise<boolean>
  • Checks whether the speakerphone is enabled.

    Note

    You can call this method either before or after joining a channel.

    Returns Promise<boolean>

    • true: The speakerphone is enabled, and the audio plays from the speakerphone.
    • false: The speakerphone is not enabled, and the audio plays from devices other than the speakerphone. For example, the headset or earpiece.

joinChannel

  • joinChannel(token: string | undefined | null, channelName: string, optionalInfo: string | undefined | null, optionalUid: number, options?: ChannelMediaOptions): Promise<void>
  • Allows a user to join a channel.

    Users in the same channel can talk to each other, and multiple users in the same channel can start a group chat. Users with different App IDs cannot call each other. You must call leaveChannel to exit the current call before joining another channel.

    A successful call of this method triggers the following callbacks:

    When the connection between the client and Agora server is interrupted due to poor network conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins the channel, the SDK triggers the RejoinChannelSuccess callback on the local client.

    Once the user joins the channel (switches to another channel), the user publishes the local audio and video streams and automatically subscribes to the audio and video streams of all the other users in the channel. Subscribing incurs all associated usage costs. To unsubscribe, set the options parameter or call the mute methods accordingly.

    Note

    A channel does not accept duplicate uids, such as two users with the same uid. If you set uid as 0, the system automatically assigns a uid.

    Warning

    Ensure that the App ID used for creating the token is the same App ID used in the create method for creating an RtcEngine object. Otherwise, CDN live streaming may fail.

    Parameters

    • token: string | undefined | null

      The token generated at your server. See Authenticate Your Users with Tokens.

    • channelName: string

      The unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
    • optionalInfo: string | undefined | null

      (Optional) Reserved for future use.

    • optionalUid: number

      (Optional) User ID. A 32-bit unsigned integer with a value ranging from 1 to (2^32-1). optionalUid must be unique. If optionalUid is not assigned (or set to 0), the SDK assigns and returns uid in the JoinChannelSuccess callback. Your app must record and maintain the returned uid since the SDK does not do so.

      The uid is represented as a 32-bit unsigned integer in the SDK. Since unsigned integers are not supported by Java, the uid is handled as a 32-bit signed integer and larger numbers are interpreted as negative numbers in Java. If necessary, the uid can be converted to a 64-bit integer through “uid&0xffffffffL”.

    • Optional options: ChannelMediaOptions

      @since v3.3.1. (Optional) The channel media options: ChannelMediaOptions.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 3(NotReady): The SDK fails to be initialized. You can try re-initializing the SDK.
      • 5(Refused): The request is rejected. Possible reasons:
        • You have created an RtcChannel object with the same channel name.
        • You have joined and published a stream in a channel created by the RtcChannel object. When you join a channel created by the RtcEngine object, the SDK publishes the local audio and video streams to that channel by default. Because the SDK does not support publishing a local stream to more than one channel simultaneously, an error occurs in this occasion.
      • 7(NotInitialized): The SDK is not initialized.
      • 17(JoinChannelRejected): The request to join the channel is rejected. The SDK supports joining only one RtcEngine channel at a time. Therefore, the SDK returns this error code when a user who has already joined an RtcEngine channel calls the joining channel method of the RtcEngine class with a valid channel name.

joinChannelWithUserAccount

  • joinChannelWithUserAccount(token: string | undefined | null, channelName: string, userAccount: string, options?: ChannelMediaOptions): Promise<void>
  • Joins the channel with a user account.

    After the user successfully joins the channel, the SDK triggers the following callbacks:

    Once the user joins the channel, the user publishes the local audio and video streams and automatically subscribes to the audio and video streams of all the other users in the channel. Subscribing incurs all associated usage costs. To unsubscribe, set the options parameter or call the mute methods accordingly.

    Note

    • To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account.
    • If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
    • Before using a String user name, ensure that you read How can I use string user names for getting details about the limitations and implementation steps.

    Parameters

    • token: string | undefined | null

      The token generated at your server. See Authenticate Your Users with Tokens.

    • channelName: string

      The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are:

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
    • userAccount: string

      The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null.

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
    • Optional options: ChannelMediaOptions

      @since v3.3.1. (Optional) The channel media options: ChannelMediaOptions.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 3(NotReady): The SDK fails to be initialized. You can try re-initializing the SDK.
      • 5(Refused): The request is rejected.
      • 17(JoinChannelRejected): The request to join the channel is rejected. The SDK supports joining only one RtcEngine channel at a time. Therefore, the SDK returns this error code when a user who has already joined an RtcEngine channel calls the joining channel method of the RtcEngine class with a valid channel name.

leaveChannel

  • leaveChannel(): Promise<void>
  • Allows a user to leave a channel.

    After joining a channel, the user must call this method to end the call before joining another channel. This method returns 0 if the user leaves the channel and releases all resources related to the call.

    This method call is asynchronous, and the user has not exited the channel when the method call returns. Once the user leaves the channel, the SDK triggers the LeaveChannel callback. A successful leaveChannel method call triggers the following callbacks:

    Note

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 1(Failed): A general error occurs (no specified reason).
      • 2(InvalidArgument): The parameter is invalid.
      • 7(NotInitialized): The SDK is not initialized.

muteAllRemoteAudioStreams

  • muteAllRemoteAudioStreams(muted: boolean): Promise<void>
  • Stops or resumes subscribing to the audio streams of all remote users.

    After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all remote users, including all subsequent users.

    Note

    • Call this method after joining a channel.
    • As of v3.3.1, this method contains the function of setDefaultMuteAllRemoteAudioStreams. Agora recommend not calling muteAllRemoteAudioStreams and setDefaultMuteAllRemoteAudioStreams together; otherwise, the settings may not take effect. See Set the Subscribing State.

    Parameters

    • muted: boolean

      Sets whether to stop subscribing to the audio streams of all remote users.

      • true: Stop subscribing to the audio streams of all remote users.
      • false: (Default) Resume subscribing to the audio streams of all remote users.

    Returns Promise<void>

muteAllRemoteVideoStreams

  • muteAllRemoteVideoStreams(muted: boolean): Promise<void>
  • Stops or resumes subscribing to the video streams of all remote users.

    After successfully calling this method, the local user stops or resumes subscribing to the video streams of all remote users, including all subsequent users.

    Note

    • Call this method after joining a channel.
    • As of v3.3.1, this method contains the function of setDefaultMuteAllRemoteVideoStreams. Agora recommend not calling muteAllRemoteVideoStreams and setDefaultMuteAllRemoteVideoStreams together; otherwise, the settings may not take effect. See Set the Subscribing State.

    Parameters

    • muted: boolean

      Sets whether to stop subscribing to the video streams of all remote users.

      • true: Stop subscribing to the video streams of all remote users.
      • false: (Default) Resume subscribing to the video streams of all remote users.

    Returns Promise<void>

muteLocalAudioStream

  • muteLocalAudioStream(muted: boolean): Promise<void>
  • Stops or resumes publishing the local audio stream.

    As of v3.4.5, this method only sets the publishing state of the audio stream in the channel of RtcEngine.

    A successful method call triggers the UserMuteAudio callback on the remote client.

    You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call muteLocalAudioStream(false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED).

    Note

    • This method does not change the usage state of the audio-capturing device.
    • Whether this method call takes effect is affected by the joinChannel and setClientRole methods. For details, see Set the Publishing State.

    Parameters

    • muted: boolean

      Sets whether to stop publishing the local audio stream.

      • true: Stop publishing the local audio stream.
      • false: Resume publishing the local audio stream.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • -5 (ERR_REFUSED): The request is rejected.

muteLocalVideoStream

  • muteLocalVideoStream(muted: boolean): Promise<void>
  • Stops or resumes publishing the local video stream.

    As of v3.4.5, this method only sets the publishing state of the video stream in the channel of RtcEngine.

    A successful method call triggers the UserMuteVideo callback on the remote client.

    You can only publish the local stream in one channel at a time. If you create multiple channels, ensure that you only call muteLocalVideoStream(false) in one channel; otherwise, the method call fails, and the SDK returns -5 (ERR_REFUSED).

    Note

    • This method does not change the usage state of the video-capturing device.
    • Whether this method call takes effect is affected by the joinChannel and setClientRole methods. For details, see Set the Publishing State.

    Parameters

    • muted: boolean

      Sets whether to stop publishing the local video stream.

      • true: Stop publishing the local video stream.
      • false: Resume publishing the local video stream.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • -5 (ERR_REFUSED): The request is rejected.

muteRemoteAudioStream

  • muteRemoteAudioStream(uid: number, muted: boolean): Promise<void>
  • Stops or resumes subscribing to the audio stream of a specified user.

    Note

    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • uid: number

      The user ID of the specified remote user.

    • muted: boolean

      Sets whether to stop subscribing to the audio stream of a specified user.

      • true: Stop subscribing to the audio stream of a specified user.
      • false: (Default) Resume subscribing to the audio stream of a specified user.

    Returns Promise<void>

muteRemoteVideoStream

  • muteRemoteVideoStream(uid: number, muted: boolean): Promise<void>
  • Stops or resumes subscribing to the video stream of a specified user.

    Note

    • Call this method after joining a channel.
    • See recommended settings in Set the Subscribing State.

    Parameters

    • uid: number

      The user ID of the specified remote user.

    • muted: boolean

      Sets whether to stop subscribing to the video stream of a specified user.

      • true: Stop subscribing to the video stream of a specified user.
      • false: (Default) Resume subscribing to the video stream of a specified user.

    Returns Promise<void>

pauseAllChannelMediaRelay

  • pauseAllChannelMediaRelay(): Promise<void>
  • Pauses the media stream relay to all destination channels.

    since

    v3.5.2

    After the cross-channel media stream relay starts, you can call this method to pause relaying media streams to all destination channels; after the pause, if you want to resume the relay, call resumeAllChannelMediaRelay.

    After a successful method call, the SDK triggers the ChannelMediaRelayEvent callback to report whether the media stream relay is successfully paused.

    Note Call this method after the startChannelMediaRelay method.

    Returns Promise<void>

pauseAllEffects

  • pauseAllEffects(): Promise<void>
  • Pauses all audio effects.

    Returns Promise<void>

pauseAudioMixing

  • pauseAudioMixing(): Promise<void>
  • Pauses playing and mixing the music file.

    Call this method when you are in a channel.

    Returns Promise<void>

pauseEffect

  • pauseEffect(soundId: number): Promise<void>
  • Pauses a specified audio effect.

    Parameters

    • soundId: number

      ID of the audio effect. Each audio effect has a unique ID.

    Returns Promise<void>

playEffect

  • playEffect(soundId: number, filePath: string, loopCount: number, pitch: number, pan: number, gain: number, publish: Boolean, startPos?: undefined | number): Promise<void>
  • Plays a specified local or online audio effect file.

    With this method, you can set the loop count, pitch, pan, and gain of the audio effect file and whether the remote user can hear the audio effect. To play multiple audio effect files simultaneously, call this method multiple times with different soundId and filePath. We recommend playing no more than three audio effect files at the same time. When the audio effect file playback is finished, the SDK triggers the AudioEffectFinished callback.

    Note For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK support.

    Parameters

    • soundId: number

      ID of the specified audio effect. Each audio effect has a unique ID. If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method.

    • filePath: string

      The file path, including the filename extensions.

      • On Android: To access an online file, Agora supports using a URL address; to access a local file, Agora supports using a URI address, an absolute path, or a path that starts with /assets/. Note: You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: "content://com.android.providers.media.documents/document/audio%3A14441".
      • On iOS: To access an online file, Agora supports using a URL address; to access a local file, Agora supports using an absolute path. For example: /var/mobile/Containers/Data/audio.mp4.
    • loopCount: number

      The number of times the audio effect loops:

      • ≥ 0: The number of loops. For example, 1 means loop one time, which means play the audio effect two times in total.
      • -1: Play the audio effect in an indefinite loop.
    • pitch: number

      Sets the pitch of the audio effect. The value ranges between 0.5 and 2. The default value is 1 (no change to the pitch). The lower the value, the lower the pitch.

    • pan: number

      Sets the spatial position of the audio effect. The value ranges between -1.0 and 1.0.

      • 0.0: The audio effect shows ahead.
      • 1.0: The audio effect shows on the right.
      • -1.0: The audio effect shows on the left.
    • gain: number

      Sets the volume of the audio effect. The value ranges between 0.0 and 100,0. The default value is 100.0. The lower the value, the lower the volume of the audio effect.

    • publish: Boolean

      Set whether to publish the specified audio effect to the remote stream:

      • true: The locally played audio effect is published to the Agora Cloud and the remote users can hear it.
      • false: The locally played audio effect is not published to the Agora Cloud and the remote users cannot hear it.
    • Optional startPos: undefined | number

      @since v3.4.2 The playback position (ms) of the audio effect file.

    Returns Promise<void>

preloadEffect

  • preloadEffect(soundId: number, filePath: string): Promise<void>
  • Preloads a specified audio effect file into the memory.

    Note

    • This method does not support online audio effect files.
    • To ensure smooth communication, limit the size of the audio effect file. We recommend using this method to preload the audio effect before calling joinChannel.

    Note For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK support.

    Parameters

    • soundId: number

      ID of the audio effect. Each audio effect has a unique ID.

    • filePath: string

      The file path, including the filename extensions.

      • On Android: Agora supports using a URI address, an absolute path, or a path that starts with /assets/. Note: You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: "content://com.android.providers.media.documents/document/audio%3A14441".
      • On iOS: Agora supports using an absolute path. For example: "/var/mobile/Containers/Data/audio.mp4".

    Returns Promise<void>

rate

  • rate(callId: string, rating: Rate, description?: undefined | string): Promise<void>
  • Allows the user to rate a call after the call ends.

    Parameters

    • callId: string

      ID of the call retrieved from the getCallId method.

    • rating: Rate

      Rating of the call. The value is between 1 (lowest score) and 5 (highest score). If you set a value out of this range, the InvalidArgument(-2) error occurs.

    • Optional description: undefined | string

      (Optional) The description of the rating. The string length must be less than 800 bytes.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 3(NotReady): The SDK fails to be initialized. You can try re-initializing the SDK.

registerLocalUserAccount

  • registerLocalUserAccount(appId: string, userAccount: string): Promise<void>
  • Registers a user account.

    Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the LocalUserRegistered callback on the local client, reporting the user ID and user account of the local user.

    To join a channel with a user account, you can choose either of the following:

    The difference between the two is that for the former, the time elapsed between calling the joinChannelWithUserAccount method and joining the channel is shorter than the latter.

    Note

    • Ensure that you set the userAccount parameter. Otherwise, this method does not take effect.
    • Ensure that the value of the userAccount parameter is unique in the channel.
    • To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.

    Parameters

    • appId: string

      The App ID of your project.

    • userAccount: string

      The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".

    Returns Promise<void>

registerMediaMetadataObserver

  • registerMediaMetadataObserver(): Promise<void>
  • Registers the metadata observer.

    This method enables you to add synchronized metadata in the video stream for more diversified live streaming interactions, such as sending shopping links, digital coupons, and online quizzes.

    Note

    Call this method before the joinChannel method.

    Returns Promise<void>

removeAllListeners

  • removeAllListeners<EventType>(event?: EventType): void

removeListener

  • removeListener<EventType>(event: EventType, listener: RtcEngineEvents[EventType], subscription?: EmitterSubscription): void
  • Removes the RtcEngineEvents handler.

    For callback events that you only want to listen for once, call this method to remove the specific RtcEngineEvents objects after you have received them.

    Type parameters

    Parameters

    • event: EventType

      The event type.

    • listener: RtcEngineEvents[EventType]

      The RtcEngineEvents handler.

    • Optional subscription: EmitterSubscription

    Returns void

removePublishStreamUrl

  • removePublishStreamUrl(url: string): Promise<void>
  • Removes an RTMP or RTMPS stream from the CDN.

    deprecated

    This method is deprecated as of v3.6.2. See Release Notes for an alternative solution.

    This method removes the CDN streaming URL (added by addPublishStreamUrl) from a CDN live stream. The SDK reports the result of this method call in the RtmpStreamingStateChanged callback.

    Note

    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Push Streams to CDN.
    • Ensure that the user joins a channel before calling this method.
    • This method applies to LiveBroadcasting only.
    • This method removes only one CDN streaming URL each time it is called.

    Parameters

    • url: string

      The CDN streaming URL to be removed. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.

    Returns Promise<void>

renewToken

  • renewToken(token: string): Promise<void>
  • Renews the token when the current token expires.

    The token expires after a period of time once the token schema is enabled when:

    The app should retrieve a new token from the server and call this method to renew it. Failure to do so results in the SDK disconnecting from the server.

    Parameters

    • token: string

      The new token.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 1(Failed): A general error occurs (no specified reason).
      • 2(InvalidArgument): The parameter is invalid.
      • 7(NotInitialized): The SDK is not initialized.

resumeAllChannelMediaRelay

  • resumeAllChannelMediaRelay(): Promise<void>
  • Resumes the media stream relay to all destination channels.

    since

    v3.5.2

    After calling the pauseAllChannelMediaRelay method, you can call this method to resume relaying media streams to all destination channels.

    After a successful method call, the SDK triggers the ChannelMediaRelayEvent callback to report whether the media stream relay is successfully resumed.

    Note Call this method after the pauseAllChannelMediaRelay method.

    Returns Promise<void>

resumeAllEffects

  • resumeAllEffects(): Promise<void>
  • Resumes playing all audio effects.

    Returns Promise<void>

resumeAudioMixing

  • resumeAudioMixing(): Promise<void>
  • Resumes playing and mixing the music file.

    Call this method when you are in a channel.

    Returns Promise<void>

resumeEffect

  • resumeEffect(soundId: number): Promise<void>
  • Resumes playing a specified audio effect.

    Parameters

    • soundId: number

      ID of the audio effect. Each audio effect has a unique ID.

    Returns Promise<void>

selectAudioTrack

  • selectAudioTrack(index: number): Promise<void>
  • Specifies the playback track of the current music file.

    since

    v3.5.1

    After getting the number of audio tracks of the current music file, call this method to specify any audio track to play. For example, if different tracks of a multitrack file store songs in different languages, you can call this method to set the language of the music file to play.

    Note

    Parameters

    • index: number

    Returns Promise<void>

sendCustomReportMessage

  • sendCustomReportMessage(id: string, category: string, event: string, label: string, value: number): Promise<void>
  • This function is in the beta stage with a free trial. The ability provided in its beta test version is reporting a maximum of 10 message pieces within 6 seconds, with each message piece not exceeding 256 bytes and each string not exceeding 100 bytes. To try out this function, contact support@agora.io and discuss the format of customized messages with us.

    Parameters

    • id: string
    • category: string
    • event: string
    • label: string
    • value: number

    Returns Promise<void>

sendMetadata

  • sendMetadata(metadata: string): Promise<void>
  • Sends the metadata.

    Parameters

    • metadata: string

      The metadata to be sent.

    Returns Promise<void>

sendStreamMessage

  • sendStreamMessage(streamId: number, message: string): Promise<void>
  • Sends data stream messages.

    The SDK has the following restrictions on this method:

    • Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 kB.
    • Each client can send up to 6 kB of data per second.
    • Each user can have up to five data channels simultaneously.

    A successful sendStreamMessage method call triggers the StreamMessage callback on the remote client, from which the remote user gets the stream message.

    A failed sendStreamMessage method call triggers the StreamMessageError callback on the remote client.

    Note

    Parameters

    • streamId: number

      ID of the sent data stream returned by the createDataStream method.

    • message: string

      Sent data.

    Returns Promise<void>

setAgoraLibPath

  • setAgoraLibPath(path: string): Promise<void>
  • Sets the storage directory of .so files.

    since

    v3.6.2

    By default, the SDK loads .so files from the app's nativeLibraryPath. You can call this method to specify the directory where you store .so files. After a successful method call, the SDK automatically loads .so files based on your specified directory when initializing the RtcEngine instance.

    Normally, you need to package required .so files when compiling the app, but this can increase the app package size. To reduce the app package size, you can call this method to enable the app to load required .so files dynamically when the app runs. For detailed instructions, see Reduce App Size.

    Note

    • This method applies to the Android platform only.
    • Call this method before creating an RtcEngine instance.
    • This method is applicable when you integrate the SDK manually but not when you integrate the SDK with Maven Central or JitPack.

    Parameters

    • path: string

      The directory where you store .so files, which must be a private directory of the app and can be obtained using Context.getDir(). Ensure the specified directory exists; otherwise, the SDK reports the InvalidParameterException error.

    Returns Promise<void>

setAudioEffectParameters

  • setAudioEffectParameters(preset: AudioEffectPreset, param1: number, param2: number): Promise<void>
  • Sets parameters for SDK preset audio effects.

    since

    v3.2.0.

    Call this method to set the following parameters for the local user who sends an audio stream:

    • 3D voice effect: Sets the cycle period of the 3D voice effect.
    • Pitch correction effect: Sets the basic mode and tonic pitch of the pitch correction effect. Different songs have different modes and tonic pitches. Agora recommends bounding this method with interface elements to enable users to adjust the pitch correction interactively.

    After setting parameters, all users in the channel can hear the relevant effect.

    Note

    • To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the scenario parameter to GameStreaming(3) before calling this method.
    • Do not set the profile parameter of setAudioProfile to SpeechStandard(1); otherwise, this method call does not take effect.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
    • After calling this method, Agora recommends not calling the following methods, because they can override setAudioEffectParameters:
      • setAudioEffectPreset
      • setVoiceBeautifierPreset
      • setLocalVoiceReverbPreset
      • setLocalVoiceChanger
      • setLocalVoicePitch
      • setLocalVoiceEqualization
      • setLocalVoiceReverb
      • setVoiceConversionPreset

    Parameters

    • preset: AudioEffectPreset

      The options for SDK preset audio effects:

      • 3D voice effect: RoomAcoustics3DVoice.
        • Call setAudioProfile and set the profile parameter to MusicStandardStereo(3) or MusicHighQualityStereo(5) before setting this enumerator; otherwise, the enumerator setting does not take effect.
        • If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear the anticipated voice effect.
      • Pitch correction effect: PitchCorrection. To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the profile parameter to MusicHighQuality(4) or MusicHighQualityStereo(5) before setting this enumerator.
    • param1: number
      • If you set preset to RoomAcoustics3DVoice, the param1 sets the cycle period of the 3D voice effect. The value range is [1,60] and the unit is a second. The default value is 10 seconds, indicating that the voice moves around you every 10 seconds.
      • If you set preset to PitchCorrection, param1 sets the basic mode of the pitch correction effect:
        • 1: (Default) Natural major scale.
        • 2: Natural minor scale.
        • 3: Japanese pentatonic scale.
    • param2: number
      • If you set preset to RoomAcoustics3DVoice, you need to set param2 to 0.
      • If you set preset to PitchCorrection, param2 sets the tonic pitch of the pitch correction effect:
        • 1: A
        • 2: A#
        • 3: B
        • 4: (Default) C
        • 5: C#
        • 6: D
        • 7: D#
        • 8: E
        • 9: F
        • 10: F#
        • 11: G
        • 12: G#

    Returns Promise<void>

setAudioEffectPreset

  • Sets an SDK preset audio effect.

    since

    v3.2.0.

    Call this method to set an SDK preset audio effect for the local user who sends an audio stream. This audio effect does not change the gender characteristics of the original voice. After setting an audio effect, all users in the channel can hear the effect.

    You can set different audio effects for different scenarios.

    To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the scenario parameter to GameStreaming(3) before calling this method.

    Note

    • You can call this method either before or after joining a channel.
    • Do not set the profile parameter of setAudioProfile to SpeechStandard(1); otherwise, this method call does not take effect.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
    • If you call this method and set the preset parameter to enumerators except RoomAcoustics3DVoice or PitchCorrection, do not call setAudioEffectParameters; otherwise, setAudioEffectParameters overrides this method.
    • After calling this method, Agora recommends not calling the following methods, because they can override setAudioEffectPreset:
      • setVoiceBeautifierPreset
      • setLocalVoiceReverbPreset
      • setLocalVoiceChanger
      • setLocalVoicePitch
      • setLocalVoiceEqualization
      • setLocalVoiceReverb
      • setVoiceConversionPreset

    Parameters

    Returns Promise<void>

setAudioMixingDualMonoMode

  • Sets the channel mode of the current music file.

    since

    v3.5.2

    In a stereo music file, the left and right channels can store different audio data. According to your needs, you can set the channel mode to original mode, left channel mode, right channel mode, or mixed channel mode. For example, in the KTV scenario, the left channel of the music file stores the musical accompaniment, and the right channel stores the singing voice. If you only need to listen to the accompaniment, call this method to set the channel mode of the music file to left channel mode; if you need to listen to the accompaniment and the singing voice at the same time, call this method to set the channel mode to mixed channel mode.

    Note

    Parameters

    • mode: AudioMixingDualMonoMode

      The channel mode. See [AudioMixingDualMonoMode]{@link enum.AudioMixingDualMonoMode}.

    Returns Promise<void>

setAudioMixingPitch

  • setAudioMixingPitch(pitch: number): Promise<void>
  • Sets the pitch of the local music file.

    When a local music file is mixed with a local human voice, call this method to set the pitch of the local music file only.

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • pitch: number

      Sets the pitch of the local music file by chromatic scale. The default value is 0, which means keep the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file.

    Returns Promise<void>

setAudioMixingPlaybackSpeed

  • setAudioMixingPlaybackSpeed(speed: number): Promise<void>
  • Sets the playback speed of the current music file.

    since

    v3.5.2

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • speed: number

      The playback speed. Agora recommends that you limit this value to between 50 and 400, defined as follows:

      • 50: Half the original speed.
      • 100: The original speed.
      • 400: 4 times the original speed.

    Returns Promise<void>

setAudioMixingPosition

  • setAudioMixingPosition(pos: number): Promise<void>
  • Sets the playback position (ms) of the music file to a different starting position (the default plays from the beginning).

    Note

    Call this method after calling startAudioMixing and receiving the AudioMixingStateChanged(Playing) callback.

    Parameters

    • pos: number

      The playback starting position (ms) of the audio mixing file.

    Returns Promise<void>

setAudioProfile

  • Sets the audio parameters and application scenarios.

    Note

    • You must call this method before calling joinChannel.
    • In the Communication and LiveBroadcasting profiles, the bitrates may be different from your settings due to network self-adaptation.
    • In scenarios requiring high-quality audio, we recommend setting profile as MusicHighQuality(4) and scenario as GameStreaming(3). For example, for music education scenarios.

    Parameters

    Returns Promise<void>

setAudioSessionOperationRestriction

  • The method applies to the iOS platform only. You can call this method either before or after joining a channel.

    The SDK and the app can both configure the audio session by default. The app may occasionally use other apps or third-party components to manipulate the audio session and restrict the SDK from doing so. This method allows the app to restrict the SDK’s manipulation of the audio session.

    You can call this method at any time to return the control of the audio sessions to the SDK.

    Note

    • This method restricts the SDK’s manipulation of the audio session. Any operation to the audio session relies solely on the app, other apps, or third-party components.

    Parameters

    Returns Promise<void>

setBeautyEffectOptions

  • setBeautyEffectOptions(enabled: boolean, options: BeautyOptions): Promise<void>
  • Enables/Disables image enhancement and sets the options.

    Note

    • Call this method after calling enableVideo.

    • On Android,this method applies to Android 4.4 or later.

    • Agora has updated the Agora image enhancement algorithm from v3.6.2 to enhance image enhancement effects and support sharpness adjustment. If you want to experience optimized image enhancement effects or set the sharpness, ensure that you have integrated the following dynamic library into the project before calling this method:

    • Android: libagora_video_process_extension.so

    • iOS: AgoraVideoProcessExtension.xcframework

    Parameters

    • enabled: boolean

      Sets whether to enable image enhancement:

      • true: Enable image enhancement.
      • false: Disable image enhancement.
    • options: BeautyOptions

      The image enhancement options.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 4(NotSupported): The system version is earlier than Android 4.4, which does not support this function.

setCameraAutoFocusFaceModeEnabled

  • setCameraAutoFocusFaceModeEnabled(enabled: boolean): Promise<void>
  • Enables the camera auto-face focus function.

    Parameters

    • enabled: boolean

      Sets whether to enable/disable the camera auto-face focus function:

      • true: Enable the camera auto-face focus function.
      • false: (Default) Disable the camera auto-face focus function.

    Returns Promise<void>

setCameraCapturerConfiguration

  • Sets the camera capturer configuration.

    For a video call or live interactive video streaming, generally the SDK controls the camera output parameters. When the default camera capture settings do not meet special requirements or cause performance problems, we recommend using this method to set the camera capturer configuration:

    • If the resolution or frame rate of the captured raw video data are higher than those set by setVideoEncoderConfiguration, processing video frames requires extra CPU and RAM usage and degrades performance. We recommend setting config as Performance(1) to avoid such problems.

    • If you do not need local video preview or are willing to sacrifice preview quality, we recommend setting config as Performance(1) to optimize CPU and RAM usage.

    • If you want better quality for the local video preview, we recommend setting config as Preview(2).

    • To customize the width and height of the video image captured by the local camera, set the camera capture configuration as Manual(3).

    Note

    Call this method before enabling the local camera. That said, you can call this method before calling joinChannel, enableVideo, or enableLocalVideo, depending on which method you use to turn on your local camera.

    Parameters

    Returns Promise<void>

setCameraExposurePosition

  • setCameraExposurePosition(positionXinView: number, positionYinView: number): Promise<void>
  • Sets the camera exposure position.

    A successful setCameraExposurePosition method call triggers the CameraExposureAreaChanged callback on the local client.

    Parameters

    • positionXinView: number

      The horizontal coordinate of the touch point in the view.

    • positionYinView: number

      The vertical coordinate of the touch point in the view.

    Returns Promise<void>

setCameraFocusPositionInPreview

  • setCameraFocusPositionInPreview(positionX: number, positionY: number): Promise<void>
  • Sets the camera manual focus position.

    A successful setCameraFocusPositionInPreview method call triggers the CameraFocusAreaChanged callback on the local client.

    Parameters

    • positionX: number

      The horizontal coordinate of the touch point in the view.

    • positionY: number

      The vertical coordinate of the touch point in the view.

    Returns Promise<void>

setCameraTorchOn

  • setCameraTorchOn(isOn: boolean): Promise<void>
  • Sets whether to enable the flash.

    Note Call this method after the camera is started.

    Parameters

    • isOn: boolean

      Determines whether to enable the flash:

      • true: Enable the flash.
      • false: Disable the flash.

    Returns Promise<void>

setCameraZoomFactor

  • setCameraZoomFactor(factor: number): Promise<void>
  • Sets the camera zoom ratio.

    Parameters

    • factor: number

      Sets the camera zoom factor. The value ranges between 1.0 and the maximum zoom supported by the device.

    Returns Promise<void>

setChannelProfile

  • Sets the channel profile of the Agora RtcEngine.

    After initialization, the SDK uses the communication channel profile by default. You can call setChannelProfile to set the channel profile.

    The Agora RtcEngine differentiates channel profiles and applies different optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for live interactive video streaming.

    Parameters

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 7(NotInitialized): The SDK is not initialized.

setClientRole

  • Sets the role of a user in interactive live streaming.

    After calling setChannelProfile(LiveBroadcasting), the SDK sets the user role as audience by default. You can call setClientRole to set the user role as host.

    You can call this method either before or after joining a channel. If you call this method to switch the user role after joining a channel, the SDK automatically does the following:

    Note

    • This method applies to the LiveBroadcasting profile only (when the profile parameter in setChannelProfile is set as LiveBroadcasting).
    • As of v3.2.0, this method can set the user level in addition to the user role.
      • The user role determines the permissions that the SDK grants to a user, such as permission to send local streams, receive remote streams, and push streams to a CDN address.
      • The user level determines the level of services that a user can enjoy within the permissions of the user's role. For example, an audience member can choose to receive remote streams with low latency or ultra low latency. User level affects the pricing of services.

    Parameters

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 1(Failed): A general error occurs (no specified reason).
      • 2(InvalidArgument): The parameter is invalid.
      • 5(Refused): The request is rejected. In multichannel scenarios, if you have set any of the following in one channel, the SDK returns this error code when the user switches the user role to host in another channel:
        • Call joinChannel with the options parameter and use the default settings publishLocalAudio = true or publishLocalVideo = true.
        • Call setClientRole to set the user role as host.
        • Call muteLocalAudioStream(false) or muteLocalVideoStream(false).
      • 7(NotInitialized): The SDK is not initialized.

setCloudProxy

  • Sets the Agora cloud proxy service.

    since

    v3.3.1.

    When users' network access is restricted by a firewall, configure the firewall to allow specific IP addresses and ports provided by Agora; then, call this method to enable the cloud proxy and set the cloud proxy type with the proxyType parameter.

    After a successfully cloud proxy connection, the SDK triggers the ConnectionStateChanged(Connecting, SettingProxyServer) callback.

    As of v3.6.2, when a user calls this method and then joins a channel successfully, the SDK triggers the ProxyConnected callback to report the user ID, the proxy type connected, and the time elapsed from the user calling joinChannel until this callback is triggered

    To disable the Force UDP or Force TCP cloud proxy that has been set, call setCloudProxy(None). To change the cloud proxy type that has been set, call setCloudProxy(None) first, and then call setCloudProxy with the desired proxyType.

    Note

    • Agora recommends that you call this method before joining the channel or after leaving the channel.
    • For the SDK v3.3.x, when users use the Force UDP cloud proxy, the services for Media Push and cohosting across channels are not available; for the SDK v3.4.0 or later, when users behind a firewall use the Force UDP cloud proxy, the services for Media Push and cohosting across channels are not available.
    • When you use the Force TCP cloud proxy, note the following:
      • An error occurs when calling startAudioMixing to play online music files in the HTTP protocol.
      • The services for Media Push and cohosting across channels use the cloud proxy with the TCP protocol.

    Parameters

    • proxyType: CloudProxyType

      The cloud proxy type. See CloudProxyType. This parameter is required, and the SDK reports an error if you do not pass in a value.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid.
      • 7(NotInitialized): The SDK is not initialized.

setColorEnhanceOptions

  • Sets color enhancement.

    since

    v3.6.2

    The video images captured by the camera can have color distortion. The color enhancement feature intelligently adjusts video characteristics such as saturation and contrast to enhance the video color richness and color reproduction, making the video more vivid.

    You can call this method to enable the color enhancement feature and set the options of the color enhancement effect.

    Note

    • Before calling this method, ensure that you have integrated the following dynamic library:
      • Android: libagora_video_process_extension.so
      • iOS: AgoraVideoProcessExtension.xcframework
    • Call this method after enableVideo.
    • The video noise reduction feature has certain performance requirements on devices. If your device overheats after you enable video noise reduction, Agora recommends modifying the video noise reduction options to a less performance-consuming level or disabling video noise reduction entirely.

    Parameters

    • enabled: boolean

      Sets whether to enable video noise reduction:

      • true: Enable.
      • false: (Default) Disable.
    • options: ColorEnhanceOptions

      The video noise reduction options. See ColorEnhanceOptions.

    Returns Promise<void>

setDefaultAudioRoutetoSpeakerphone

  • setDefaultAudioRoutetoSpeakerphone(defaultToSpeaker: boolean): Promise<void>
  • Sets the default audio route.

    If the default audio route of the SDK (see Set the Audio Route ) cannot meet your requirements, you can call this method to switch the default audio route. After successfully switching the audio route, the SDK triggers the AudioRouteChanged callback to indicate the changes.

    Note

    • Call this method before calling joinChannel. If you need to switch the audio route after joining a channel, call setEnableSpeakerphone.
    • If the user uses an external audio playback device such as a Bluetooth or wired headset, this method does not take effect, and the SDK plays audio through the external device. When the user uses multiple external devices, the SDK plays audio through the last connected device.

    Parameters

    • defaultToSpeaker: boolean

      Sets the default audio route as follows:

      • true: Set to the speakerphone.
      • false: Set to the earpiece.

    Returns Promise<void>

setDefaultMuteAllRemoteAudioStreams

  • setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise<void>
  • Sets whether to receive all remote audio streams by default.

    deprecated

    This method is deprecated from v3.3.1.

    Stops or resumes subscribing to the audio streams of all remote users by default.

    Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all subsequent users.

    Note If you need to resume subscribing to the audio streams of remote users in the channel after calling setDefaultMuteAllRemoteAudioStreams(true), do the following:

    Parameters

    • muted: boolean

      Sets whether to stop subscribing to the audio streams of all remote users by default.

      • true: Stop subscribing to the audio streams of all remote users by default.
      • false: (Default) Resume subscribing to the audio streams of all remote users by default.

    Returns Promise<void>

setDefaultMuteAllRemoteVideoStreams

  • setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise<void>
  • Sets whether to receive all remote video streams by default.

    deprecated

    This method is deprecated from v3.3.1.

    Stops or resumes subscribing to the video streams of all remote users by default.

    Call this method after joining a channel. After successfully calling this method, the local user stops or resumes subscribing to the video streams of all subsequent users.

    Note

    If you need to resume subscribing to the video streams of remote users in the channel after calling setDefaultMuteAllRemoteVideoStreams(true), do the following:

    Parameters

    • muted: boolean

      Sets whether to stop subscribing to the video streams of all remote users by default.

      • true: Stop subscribing to the video streams of all remote users by default.
      • false: (Default) Resume subscribing to the video streams of all remote users by default.

    Returns Promise<void>

setEffectPosition

  • setEffectPosition(soundId: number, pos: number): Promise<void>
  • Sets the playback position of an audio effect file.

    since

    v3.4.2

    After a successful setting, the local audio effect file starts playing at the specified position.

    Note Call this method after playEffect.

    Parameters

    • soundId: number

      Audio effect ID. Ensure that this parameter is set to the same value as in playEffect.

    • pos: number

      The playback position (ms) of the audio effect file.

    Returns Promise<void>

setEffectsVolume

  • setEffectsVolume(volume: number): Promise<void>
  • Sets the volume of the audio effects.

    Parameters

    • volume: number

      Volume of the audio effects. The value ranges between 0.0 and 100.0 (default).

    Returns Promise<void>

setEnableSpeakerphone

  • setEnableSpeakerphone(enabled: boolean): Promise<void>
  • Enables/Disables the audio route to the speakerphone.

    If the default audio route of the SDK (see Set the Audio Route ) or the setting in setDefaultAudioRoutetoSpeakerphone cannot meet your requirements, you can call this method to switch the current audio route. After successfully switching the audio route, the SDK triggers the AudioRouteChanged callback to indicate the changes.

    This method only sets the audio route in the current channel and does not influence the default audio route. If the user leaves the current channel and joins another channel, the default audio route is used.

    Note

    • Call this method after calling joinChannel.
    • If the user uses an external audio playback device such as a Bluetooth or wired headset, this method does not take effect, and the SDK plays audio through the external device. When the user uses multiple external devices, the SDK plays audio through the last connected device.

    Parameters

    • enabled: boolean

      Sets whether to enable the speakerphone or earpiece

      • true: Enable the speakerphone. The audio route is the speakerphone.
      • false: Disable the speakerphone. The audio route is the earpiece.

    Returns Promise<void>

setEncryptionMode

  • Sets the built-in encryption mode.

    deprecated

    Deprecated as of v3.1.2. Use enableEncryption instead.

    The Agora SDK supports built-in encryption, which is set to AES128XTS mode by default. Call this method to set the encryption mode to use other encryption modes. All users in the same channel must use the same encryption mode and password.

    Refer to the information related to the AES encryption algorithm on the differences between the encryption modes.

    Note

    Call setEncryptionSecret before calling this method.

    Parameters

    Returns Promise<void>

setEncryptionSecret

  • setEncryptionSecret(secret: string): Promise<void>
  • Enables built-in encryption with an encryption password before joining a channel.

    deprecated

    Deprecated as of v3.1.2. Use enableEncryption instead.

    All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled.

    Note

    • For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption.
    • Do not use this method for CDN live streaming.

    Parameters

    • secret: string

      The encryption password.

    Returns Promise<void>

setInEarMonitoringVolume

  • setInEarMonitoringVolume(volume: number): Promise<void>
  • Sets the volume of the in-ear monitor.

    Parameters

    • volume: number

      Sets the volume of the in-ear monitor. The value ranges between 0 and 100 (default).

    Returns Promise<void>

setLiveTranscoding

  • Sets the video layout and audio settings for CDN live.

    deprecated

    This method is deprecated as of v3.6.2. See Release Notes for an alternative solution.

    The SDK triggers the TranscodingUpdated callback when you call this method to update the LiveTranscoding class. If you call this method to set the LiveTranscoding class for the first time, the SDK does not trigger the TranscodingUpdated callback.

    Note

    • This method applies to LiveBroadcasting only.
    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Push Streams to CDN.
    • Ensure that you call setClientRole and set the user role as the host.
    • Ensure that you call setLiveTranscoding before calling addPublishStreamUrl.
    • Agora supports pushing media streams in RTMPS protocol to the CDN only when you enable transcoding.

    Parameters

    • transcoding: LiveTranscoding

      Sets the CDN live audio/video transcoding settings.

    Returns Promise<void>

setLocalPublishFallbackOption

  • Sets the fallback option for the locally published video stream based on the network conditions.

    If option is set as AudioOnly(2), the SDK will:

    • Disable the upstream video but enable audio only when the network conditions deteriorate and cannot support both video and audio.

    • Re-enable the video when the network conditions improve.

    When the locally published video stream falls back to audio only or when the audio-only stream switches back to the video, the SDK triggers the LocalPublishFallbackToAudioOnly.

    Note

    Agora does not recommend using this method for CDN live streaming, because the remote CDN live user will have a noticeable lag when the locally published video stream falls back to audio only.

    Parameters

    Returns Promise<void>

setLocalVoiceChanger

  • Sets the local voice changer option.

    deprecated

    Deprecated as of v3.2.0. Use the following methods instead:

    • setAudioEffectPreset: Audio effects.
    • setVoiceBeautifierPreset: Voice beautifier effects.
    • setVoiceConversionPreset: Voice conversion effects.

    Note

    Do not use this method together with setLocalVoiceReverbPreset, or the method called earlier does not take effect.

    Parameters

    Returns Promise<void>

setLocalVoiceEqualization

  • Sets the local voice equalization effect.

    Parameters

    • bandFrequency: AudioEqualizationBandFrequency

      Sets the band frequency. The value ranges between 0 and 9; representing the respective 10-band center frequencies of the voice effects, including 31, 62, 125, 500, 1k, 2k, 4k, 8k, and 16k Hz.

    • bandGain: number

      Sets the gain of each band (dB). The value ranges between -15 and 15. The default value is 0.

    Returns Promise<void>

setLocalVoicePitch

  • setLocalVoicePitch(pitch: number): Promise<void>
  • Changes the voice pitch of the local speaker.

    Parameters

    • pitch: number

      Sets the voice pitch. The value ranges between 0.5 and 2.0. The lower the value, the lower the voice pitch. The default value is 1.0 (no change to the local voice pitch).

    Returns Promise<void>

setLocalVoiceReverb

  • setLocalVoiceReverb(reverbKey: AudioReverbType, value: number): Promise<void>
  • Sets the local voice reverberation.

    Note

    As of v3.2.1, the SDK provides a more convenient method setAudioEffectPreset, which directly implements the popular music, R&B music, KTV and other preset reverb effects.

    Parameters

    Returns Promise<void>

setLocalVoiceReverbPreset

  • Sets the preset local voice reverberation effect.

    deprecated

    Deprecated as of v3.2.0. Use setAudioEffectPreset or setVoiceBeautifierPreset instead.

    Note

    Parameters

    Returns Promise<void>

setLogFile

  • setLogFile(filePath: string): Promise<void>
  • Sets the log files that the SDK outputs.

    deprecated

    This method is deprecated from v3.3.1. Use the LogConfig parameter in createWithConfig to set the log file path instead.

    By default, the SDK outputs five log files, agorasdk.log, agorasdk_1.log, agorasdk_2.log, agorasdk_3.log, agorasdk_4.log, each with a default size of 1024 KB. These log files are encoded in UTF-8. The SDK writes the latest logs in agorasdk.log. When agorasdk.log is full, the SDK deletes the log file with the earliest modification time among the other four, renames agorasdk.log to the name of the deleted log file, and creates a new agorasdk.log to record latest logs. The log file records all log data for the SDK’s operation. Ensure that the directory for the log file exists and is writable.

    Note

    Ensure that you call this method immediately after calling the create method, otherwise the output log may not be complete.

    Parameters

    • filePath: string

      The absolute path of log files. The default file path is as follows:

      • Android: /storage/emulated/0/Android/data/<package_name>/files/agorasdk.log
      • iOS: App Sandbox/Library/caches/agorasdk.log Ensure that the directory for the log files exists and is writable. You can use this parameter to rename the log files.

    Returns Promise<void>

setLogFileSize

  • setLogFileSize(fileSizeInKBytes: number): Promise<void>
  • Sets the size (KB) of a log file that the SDK outputs.

    deprecated

    This method is deprecated from v3.3.1. Use the LogConfig parameter in createWithConfig to set the log file path instead.

    By default, the SDK outputs five log files, agorasdk.log, agorasdk_1.log, agorasdk_2.log, agorasdk_3.log, agorasdk_4.log, each with a default size of 1024 KB. These log files are encoded in UTF-8. The SDK writes the latest logs in agorasdk.log. When agorasdk.log is full, the SDK deletes the log file with the earliest modification time among the other four, renames agorasdk.log to the name of the deleted log file, and create a new agorasdk.log to record latest logs.

    Parameters

    • fileSizeInKBytes: number

      The size (KB) of a log file. The default value is 1024 KB. If you set fileSizeInKByte to 1024 KB, the SDK outputs at most 5 MB log files; if you set it to less than 1024 KB, the maximum size of a log file is still 1024 KB.

    Returns Promise<void>

setLogFilter

  • setLogFilter(filter: LogFilter): Promise<void>
  • Sets the output log level of the SDK.

    deprecated

    This method is deprecated from v3.3.1. Use the LogConfig parameter in createWithConfig to set the log file path instead.

    You can use one or a combination of the filters. The log level follows the sequence of Off, Critical, Error, Warning, Info, and Debug. Choose a level to see the logs preceding that level. For example, if you set the log level to Warning, you see the logs within levels Critical, Error, and Warning.

    Parameters

    • filter: LogFilter

      Sets the log filter level.

    Returns Promise<void>

setLowLightEnhanceOptions

  • Sets low-light enhancement.

    since

    v3.6.2

    The low-light enhancement feature can adaptively adjust the brightness value of the video captured in situations with low or uneven lighting, such as backlit, cloudy, or dark scenes. It restores or highlights the image details and improves the overall visual effect of the video.

    You can call this method to enable the low-light enhancement feature and set the options of the low-light enhancement effect.

    Note

    • Before calling this method, ensure that you have integrated the following dynamic library:
      • Android: libagora_video_process_extension.so
      • iOS: AgoraVideoProcessExtension.xcframework
    • Call this method after enableVideo.
    • The low-light enhancement feature has certain performance requirements on devices. If your device overheats after you enable low-light enhancement, Agora recommends modifying the low-light enhancement options to a less performance-consuming level or disabling low-light enhancement entirely.

    Parameters

    Returns Promise<void>

setMaxMetadataSize

  • setMaxMetadataSize(size: number): Promise<void>
  • Sets the maximum size of the metadata.

    Parameters

    • size: number

      Buffer size of the sent or received metadata.

    Returns Promise<void>

setRemoteDefaultVideoStreamType

  • setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise<void>
  • Sets the default video-stream type of the remotely subscribed video stream when the remote user sends dual streams.

    Note

    • This method can only be called before joining a channel. Agora does not support you to change the default subscribed video stream type after joining a channel.
    • If you call both this method and setRemoteVideoStreamType, the SDK applies the settings in the setRemoteVideoStreamType method.

    Parameters

    Returns Promise<void>

setRemoteSubscribeFallbackOption

  • Sets the fallback option for the remotely subscribed video stream based on the network conditions.

    If option is set as AudioOnly(2), the SDK automatically switches the video from a high-stream to a low-stream, or disables the video when the downlink network condition cannot support both audio and video to guarantee the quality of the audio. The SDK monitors the network quality and restores the video stream when the network conditions improve. When the remotely subscribed video stream falls back to audio only, or the audio-only stream switches back to the video, the SDK triggers the RemoteSubscribeFallbackToAudioOnly callback.

    Parameters

    Returns Promise<void>

setRemoteUserPriority

  • setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise<void>
  • Sets the priority of a remote user's media stream.

    Use this method with the setRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality.

    Note

    The Agora SDK supports setting userPriority as high for one user only.

    Parameters

    • uid: number

      The ID of the remote user.

    • userPriority: UserPriority

      The priority of the remote user.

    Returns Promise<void>

setRemoteVideoStreamType

  • setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise<void>
  • Sets the stream type of the remote video.

    Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode(false), the receiver can choose to receive either the high-video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream).

    By default, users receive the high-video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources.

    The aspect ratio of the low-video stream is the same as the high-video stream. Once the resolution of the high-video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream.

    The SDK reports the result of calling this method in the ApiCallExecuted callback.

    Note

    You can call this method either before or after joining a channel. If you call both setRemoteVideoStreamType and setRemoteDefaultVideoStreamType, the SDK applies the settings in the setRemoteVideoStreamType method.

    Parameters

    • uid: number

      ID of the remote user sending the video stream.

    • streamType: VideoStreamType

      Sets the video-stream type.

    Returns Promise<void>

setRemoteVoicePosition

  • setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise<void>
  • Sets the sound position of a remote user.

    When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games.

    Note

    • For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel.

    • This method requires hardware support. For the best sound positioning, we recommend using a wired headset.

    Parameters

    • uid: number

      The ID of the remote user.

    • pan: number

      The sound position of the remote user. The value ranges from -1.0 to 1.0:

      • 0.0: The remote sound comes from the front.
      • -1.0: The remote sound comes from the left.
      • 1.0: The remote sound comes from the right.
    • gain: number

      Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.

    Returns Promise<void>

setVideoDenoiserOptions

  • Sets video noise reduction.

    since

    v3.6.2

    Underlit environments and low-end video capture devices can cause video images to contain significant noise, which affects video quality. In real-time interactive scenarios, video noise also consumes bitstream resources and reduces encoding efficiency during encoding.

    You can call this method to enable the video noise reduction feature and set the options of the video noise reduction effect.

    Note

    • Before calling this method, ensure that you have integrated the following dynamic library:
      • Android: libagora_video_process_extension.so
      • iOS: AgoraVideoProcessExtension.xcframework
    • Call this method after enableVideo.
    • The video noise reduction feature has certain performance requirements on devices. If your device overheats after you enable video noise reduction, Agora recommends modifying the video noise reduction options to a less performance-consuming level or disabling video noise reduction entirely.

    Parameters

    Returns Promise<void>

setVideoEncoderConfiguration

  • Sets the video encoder configuration.

    Each video encoder configuration corresponds to a set of video parameters, including the resolution, frame rate, bitrate, and video orientation. The parameters specified in this method are the maximum values under ideal network conditions. If the video engine cannot render the video using the specified parameters due to poor network conditions, the parameters further down the list are considered until a successful configuration is found. If you do not set the video encoder configuration after joining the channel, you can call this method before calling enableVideo to reduce the render time of the first video frame.

    Parameters

    Returns Promise<void>

setVoiceBeautifierParameters

  • setVoiceBeautifierParameters(preset: VoiceBeautifierPreset, param1: number, param2: number): Promise<void>
  • Sets parameters for SDK preset voice beautifier effects.

    since

    3.3.1.

    Call this method to set a gender characteristic and a reverberation effect for the singing beautifier effect. This method sets parameters for the local user who sends an audio stream.

    After you call this method successfully, all users in the channel can hear the relevant effect.

    To achieve better audio effect quality, before you call this method, Agora recommends calling setAudioProfile, and setting the scenario parameter to GameStreaming(3) and the profile parameter to MusicHighQuality(4) or MusicHighQualityStereo(5).

    Note

    • You can call this method either before or after joining a channel.
    • Do not set the profile parameter of setAudioProfile to SpeechStandard(1); otherwise, this method call does not take effect.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
    • After you call this method, Agora recommends not calling the following methods, because they can override setVoiceBeautifierParameters:
      • setAudioEffectPreset
      • setAudioEffectParameters
      • setVoiceBeautifierPreset
      • setLocalVoiceReverbPreset
      • setLocalVoiceChanger
      • setLocalVoicePitch
      • setLocalVoiceEqualization
      • setLocalVoiceReverb
      • setVoiceConversionPreset

    Parameters

    • preset: VoiceBeautifierPreset

      The options for SDK preset voice beautifier effects: - SingingBeautifier: Singing beautifier effect.

    • param1: number

      The gender characteristics options for the singing voice: - 1: A male-sounding voice. - 2: A female-sounding voice.

    • param2: number

      The reverberation effects options: - 1: The reverberation effect sounds like singing in a small room. - 2: The reverberation effect sounds like singing in a large room. - 3: The reverberation effect sounds like singing in a hall.

    Returns Promise<void>

setVoiceBeautifierPreset

  • Sets an SDK preset voice beautifier effect.

    since

    v3.2.0.

    Call this method to set an SDK preset voice beautifier effect for the local user who sends an audio stream. After setting a voice beautifier effect, all users in the channel can hear the effect.

    You can set different voice beautifier effects for different scenarios.

    To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the scenario parameter to GameStreaming(3) and the profile parameter to MusicHighQuality(4) or MusicHighQualityStereo(5) before calling this method.

    Note

    • You can call this method either before or after joining a channel.
    • Do not set the profile parameter of setAudioProfile to SpeechStandard(1); otherwise, this method call does not take effect.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
    • After calling this method, Agora recommends not calling the following methods, because they can override setVoiceBeautifierPreset:
      • setAudioEffectPreset
      • setAudioEffectParameters
      • setLocalVoiceReverbPreset
      • setLocalVoiceChanger
      • setLocalVoicePitch
      • setLocalVoiceEqualization
      • setLocalVoiceReverb
      • setVoiceConversionPreset

    Parameters

    Returns Promise<void>

setVoiceConversionPreset

  • Sets an SDK preset voice conversion effect.

    since

    v3.3.1

    Call this method to set an SDK preset voice conversion effect for the local user who sends an audio stream. After setting a voice conversion effect, all users in the channel can hear the effect.

    You can set different voice conversion effects for different scenarios. See Set the Voice Effect.

    To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the scenario parameter to GameStreaming(3) and the profile parameter to MusicHighQuality(4) or MusicHighQualityStereo(5) before calling this method.

    Note

    • You can call this method either before or after joining a channel.
    • Do not set the profile parameter of setAudioProfile to SpeechStandard(1); otherwise, this method call does not take effect.
    • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
    • After calling this method, Agora recommends not calling the following methods, because they can override setVoiceConversionPreset:
      • setAudioEffectPreset
      • setAudioEffectParameters
      • setVoiceBeautifierPreset
      • setVoiceBeautifierParameters
      • setLocalVoiceReverbPreset
      • setLocalVoiceChanger
      • setLocalVoicePitch
      • setLocalVoiceEqualization
      • setLocalVoiceReverb

    Parameters

    Returns Promise<void>

setVolumeOfEffect

  • setVolumeOfEffect(soundId: number, volume: number): Promise<void>
  • Sets the volume of a specified audio effect.

    Parameters

    • soundId: number

      ID of the audio effect. Each audio effect has a unique ID.

    • volume: number

      Volume of the audio effect. The value ranges between 0.0 and 100.0 (default).

    Returns Promise<void>

startAudioMixing

  • startAudioMixing(filePath: string, loopback: boolean, replace: boolean, cycle: number, startPos?: undefined | number): Promise<void>
  • Starts playing and mixing the music file.

    This method mixes the specified local or online audio file with the audio stream from the microphone, or replaces the microphone’s audio stream with the specified local or remote audio file. You can choose whether the other user can hear the local audio playback and specify the number of playback loops. When the audio mixing file playback finishes after calling this method, the SDK triggers the AudioMixingFinished callback.

    A successful call of this method triggers the AudioMixingStateChanged callback and reports Playing on the local client.

    When the audio mixing file playback finishes, the SDK triggers the AudioMixingStateChanged callback and reports Stopped on the local client.

    Note

    • To use this method on Android, ensure that the Android device is v4.2 or later, and the API version is v16 or later.

    • If you want to play an online music file, ensure that the time interval between calling this method is more than 100 ms, or the TooFrequentCall(702) error occurs.

    • If you want to play an online music file, Agora does not recommend using the redirected URL address. Some Android devices may fail to open a redirected URL address.

    • If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns CanNotOpen(701).

    • If you call this method on an emulator, only the MP3 file format is supported.

    • For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK support.

    Parameters

    • filePath: string

      The file path, including the filename extensions.

      • On Android: To access an online file, Agora supports using a URL address; to access a local file, Agora supports using a URI address, an absolute path, or a path that starts with /assets/. Note: You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: "content://com.android.providers.media.documents/document/audio%3A14441".
      • On iOS: To access an online file, Agora supports using a URL address; to access a local file, Agora supports using an absolute path. For example: /var/mobile/Containers/Data/audio.mp4.
    • loopback: boolean

      Sets which user can hear the audio mixing:

      • true: Only the local user can hear the audio mixing.
      • false: Both users can hear the audio mixing.
    • replace: boolean

      Sets the audio mixing content:

      • true: Only publish the specified audio file; the audio stream from the microphone is not published.
      • false: The local audio file is mixed with the audio stream from the microphone.
    • cycle: number

      Sets the number of playback loops:

      • Positive integer: Number of playback loops.
      • -1: Infinite playback loops.
    • Optional startPos: undefined | number

      @since v3.4.2 The playback position (ms) of the music file.

    Returns Promise<void>

startAudioRecording

  • Starts an audio recording on the client.

    deprecated

    Deprecated from v3.4.2. Use startAudioRecordingWithConfig instead.

    The SDK allows recording during a call. After successfully calling this method, you can record the audio of all the users in the channel and get an audio recording file.

    Supported formats of the recording file are as follows:

    • .wav: Large file size with high fidelity.
    • .aac: Small file size with low fidelity.

    Note

    • Ensure that the directory to save the recording file exists and is writable.
    • This method is usually called after calling joinChannel. The recording automatically stops when you call leaveChannel.
    • For better recording effects, set quality as Medium or High when sampleRate is 44.1 kHz or 48 kHz.

    Parameters

    • filePath: string

      Absolute file path (including the suffixes of the filename) of the recording file. The string of the file name is in UTF-8. For example, /sdcard/emulated/0/audio/aac.

    • sampleRate: AudioSampleRateType

      Sample rate (Hz) of the recording file.

    • quality: AudioRecordingQuality

      The audio recording quality.

    Returns Promise<void>

startAudioRecordingWithConfig

  • Starts an audio recording on the client.

    since

    v3.4.2

    The SDK allows recording audio during a call. After successfully calling this method, you can record the audio of users in the channel and get an audio recording file. Supported file formats are as follows:

    • WAV: High-fidelity files with typically larger file sizes. For example, if the sample rate is 32,000 Hz, the file size for 10-minute recording is approximately 73 MB.
    • AAC: Low-fidelity files with typically smaller file sizes. For example, if the sample rate is 32,000 Hz and the recording quality is Medium, the file size for 10-minute recording is approximately 2 MB.

    Once the user leaves the channel, the recording automatically stops.

    Note Call this method after joining a channel.

    Parameters

    Returns Promise<void>

startChannelMediaRelay

startEchoTest

  • Starts an audio call test.

    In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly.

    Note

    • Call this method before joining a channel.

    • After calling this method, call stopEchoTest to end the test. Otherwise, the app cannot run the next echo test, or call joinChannel.

    • In the LiveBroadcasting profile, only a host can call this method.

    Parameters

    • Optional intervalInSeconds: undefined | number

      The time interval (s) between when you speak and when the recording plays back.

    • Optional config: EchoTestConfiguration

    Returns Promise<void>

startLastmileProbeTest

  • Starts the last-mile network probe test before joining a channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).

    Once this method is enabled, the SDK returns the following callbacks:

    • LastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.

    • LastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.

    Call this method to check the uplink network quality before users join a channel or before an audience switches to a host.

    Note

    • This method consumes extra network traffic and may affect communication quality. We do not recommend calling this method together with enableLastmileTest.
    • Do not call other methods before receiving the LastmileQuality and LastmileProbeResult callbacks. Otherwise, the callbacks may be interrupted by other methods.
    • In the LiveBroadcasting profile, a host should not call this method after joining a channel.

    Parameters

    Returns Promise<void>

startPreview

  • startPreview(): Promise<void>
  • Starts the local video preview before joining a channel.

    Before calling this method, you must call the enableVideo method to enable the video.

    Note

    • By default, the local preview enables the mirror mode.
    • Once you call this method to start the local video preview, if you leave the channel by calling leaveChannel, the local video preview remains until you call stopPreview to disable it.

    Returns Promise<void>

startRecording

  • Starts recording the local audio and video.

    since

    v3.6.2

    You can call this method to enable the recording of the local audio and video.

    This method can record the following content:

    • The audio captured by the local microphone and encoded in AAC format.
    • The video captured by the local camera and encoded by the SDK.

    The SDK can generate a recording file only when it detects the recordable audio and video streams; when there are no audio and video streams to be recorded or the audio and video streams are interrupted for more than five seconds, the SDK stops recording and triggers the RecorderStateChanged(-1, 2) callback.

    Note Call this method after joining the channel.

    Parameters

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): The parameter is invalid. Ensure the following:
        • The specified path of the recording file exists and is writable.
        • The specified format of the recording file is supported.
        • The maximum recording duration is correctly set.
      • 4(NotSupported): RtcEngine does not support the request due to one of the following reasons:
        • The recording is ongoing.
        • The recording stops because an error occurs.
      • 7(NotInitialized): The SDK is not initialized before calling this method.

startRhythmPlayer

  • startRhythmPlayer(sound1: string, sound2: string, config: RhythmPlayerConfig): Promise<void>
  • Enables the virtual metronome.

    since

    v3.4.2

    In music education, physical education, and other scenarios, teachers often need to use a metronome so that students can practice at the correct tempo. A meter is composed of a downbeat and some number of upbeats (including zero). The first beat of each measure is called the downbeat, and the rest are called the upbeats. In this method, you need to set the paths of the upbeat and downbeat files, the number of beats per measure, the tempo, and whether to send the sound of the metronome to remote users.

    Note

    • After enabling the virtual metronome, the SDK plays the specified files from the beginning and controls the beat duration according to the value you set in beatsPerMinute. If the file duration exceeds the beat duration, the SDK only plays the audio within the beat duration.
    • For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK support.

    Parameters

    • sound1: string

      The absolute path or URL address (including the filename extensions) of the file for the downbeat.

      • Android: For example: /sdcard/emulated/0/audio.mp4.
      • iOS: For example: /var/mobile/Containers/Data/audio.mp4.
    • sound2: string

      The absolute path or URL address (including the filename extensions) of the file for the upbeats.

      • Android: For example: /sdcard/emulated/0/audio.mp4.
      • iOS: For example: /var/mobile/Containers/Data/audio.mp4.
    • config: RhythmPlayerConfig

      The metronome configuration. See RhythmPlayerConfig.

    Returns Promise<void>

startRtmpStreamWithTranscoding

  • startRtmpStreamWithTranscoding(url: string, transcoding: LiveTranscoding): Promise<void>
  • Starts pushing media streams to a CDN and sets the transcoding configuration.

    since

    v3.6.2

    You can call this method to push a live audio-and-video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.

    After you call this method, the SDK triggers the RtmpStreamingStateChanged callback on the local client to report the state of the streaming.

    Note

    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Media Push.
    • Call this method after joining a channel.
    • Only hosts in the LiveBroadcasting profile can call this method.
    • If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.

    Parameters

    • url: string

      The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.

    • transcoding: LiveTranscoding

      The transcoding configuration for CDN live streaming. See LiveTranscoding.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): url is null or the string length is 0.
      • 7(NotInitialized): The SDK is not initialized before calling this method.

startRtmpStreamWithoutTranscoding

  • startRtmpStreamWithoutTranscoding(url: string): Promise<void>
  • Starts pushing media streams to a CDN without transcoding.

    since

    v3.6.2

    You can call this method to push a live audio-and-video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.

    After you call this method, the SDK triggers the RtmpStreamingStateChanged callback on the local client to report the state of the streaming.

    Note

    • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Media Push.
    • Call this method after joining a channel.
    • Only hosts in the LiveBroadcasting profile can call this method.
    • If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.

    Parameters

    • url: string

      The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2(InvalidArgument): url is null or the string length is 0.
      • 7(NotInitialized): The SDK is not initialized before calling this method.

startScreenCapture

  • Starts screen sharing.

    since

    v3.7.0

    On Android, during screen sharing, make sure the following:

    • The user has granted screen capture permission to the application; otherwise, the SDK triggers the LocalVideoStateChanged callback and reports ScreenCapturePermissionDenied(16).
    • the Android API level is not earlier than 21; otherwise, the method call fails and returns the error code 2.
    • To capture system audio during screen sharing, ensure that the Android API level is not earlier than 29 as well; otherwise, the method call fails and returns the error code 3.

    On iOS, When the screen sharing extension process starts, ends, or quits unexpectedly, the SDK triggers the LocalVideoStateChanged callback and reports ExtensionCaptureStarted(13), ExtensionCaptureStoped(14), and ExtensionCaptureDisconnected(15) accordingly.

    Note

    • Call this method after joining a channel.
    • The billing of the screen sharing stream is based on the value of dimensions in ScreenCaptureParameters. When you do not pass in a value, Agora bills you at 1280 × 720; when you pass a value in, Agora bills you at that value. For details, see Pricing for Real-time Communication.
    • On iOS, note the following:
      • This feature is only available for iOS 11 or later.
      • This feature requires a high-performance device. Agora recommends that you use this feature on iPhone X or later models.
      • If you are using the custom audio source instead of the SDK to capture audio, Agora recommends you add the keep-alive processing logic to your application to avoid screen sharing stopping when the application goes to the background.
    • On Android, note the following:
      • On Android 9 and later, to avoid the application being killed by the system after going to the background, Agora recommends you add the foreground service permission (android.permission.FOREGROUND_SERVICE) to the /app/Manifests/AndroidManifest.xml file.
      • Due to performance limitations, screen sharing is not supported on Android TV.
      • Due to system limitations, if you are using Huawei phones, do not adjust the video encoding resolution of the screen sharing stream during the screen sharing, or you could experience crashes.

    Parameters

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 2: Due to system limitations, screen capture is not available on systems earlier than Android 5 (that is, Android API level 21). The SDK reports this error code when you call startScreenCapture on systems earlier than Android 5.
      • 3: Due to system limitations, system audio cannot be captured on systems earlier than Android 10 (that is, API level 29). The SDK reports this error when you call startScreenCapture and set captureAudio as true on systems later than Android 5 (API level 21) and earlier than Android 10 (API level 29).

stopAllEffects

  • stopAllEffects(): Promise<void>
  • Stops playing all audio effects.

    Returns Promise<void>

stopAudioMixing

  • stopAudioMixing(): Promise<void>
  • Stops playing or mixing the music file.

    Call this method when you are in a channel.

    Returns Promise<void>

stopAudioRecording

  • stopAudioRecording(): Promise<void>
  • Stops the audio recording on the client.

    Returns Promise<void>

stopChannelMediaRelay

  • stopChannelMediaRelay(): Promise<void>

stopEchoTest

  • stopEchoTest(): Promise<void>
  • Stops the audio call test.

    Returns Promise<void>

stopEffect

  • stopEffect(soundId: number): Promise<void>
  • Stops playing a specified audio effect.

    Note

    If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method.

    Parameters

    • soundId: number

      ID of the specified audio effect. Each audio effect has a unique ID.

    Returns Promise<void>

stopLastmileProbeTest

  • stopLastmileProbeTest(): Promise<void>
  • Stops the last-mile network probe test.

    Returns Promise<void>

stopPreview

  • stopPreview(): Promise<void>
  • Stops the local video preview and the video.

    Note

    Call this method after you start the local video preview and before you join the channel.

    Returns Promise<void>

stopRecording

  • stopRecording(): Promise<void>
  • Stops recording the local audio and video.

    since

    v3.6.2

    Note After calling startRecording, if you want to stop the recording, you must call stopRecording; otherwise, the generated recording files might not be playable.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 7(NotInitialized): The SDK is not initialized before calling this method.

stopRhythmPlayer

  • stopRhythmPlayer(): Promise<void>
  • Disables the virtual metronome.

    since

    v3.4.2

    After calling startRhythmPlayer, you can call this method to disable the virtual metronome.

    Returns Promise<void>

stopRtmpStream

  • stopRtmpStream(url: string): Promise<void>
  • Stops pushing media streams to a CDN.

    since

    v3.6.2

    You can call this method to stop the live stream on the specified CDN address. This method can stop pushing media streams to only one CDN address at a time, so if you need to stop pushing streams to multiple addresses, call this method multiple times.

    After you call this method, the SDK triggers the RtmpStreamingStateChanged callback on the local client to report the state of the streaming.

    Parameters

    • url: string

      The address of the CDN live streaming. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.

    Returns Promise<void>

stopScreenCapture

  • stopScreenCapture(): Promise<void>
  • Stops screen sharing.

    since

    v3.7.0

    Returns Promise<void>

switchCamera

  • switchCamera(): Promise<void>
  • Switches between front and rear cameras.

    Returns Promise<void>

switchChannel

  • switchChannel(token: string | undefined | null, channelName: string, options?: ChannelMediaOptions): Promise<void>
  • Switches to a different channel.

    This method allows the audience of a LiveBroadcasting channel to switch to a different channel.

    After the user successfully switches to another channel, the LeaveChannel and JoinChannelSuccess callbacks are triggered to indicate that the user has left the original channel and joined a new one.

    Once the user joins the channel (switches to another channel), the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. If you do not want to subscribe to a specified stream or all remote streams, call the mute methods accordingly.

    Note

    This method applies to the Audience role in a LiveBroadcasting channel only.

    Parameters

    • token: string | undefined | null

      The token generated at your server. See Authenticate Your Users with Tokens.

    • channelName: string

      Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:

      • All lowercase English letters: a to z.
      • All uppercase English letters: A to Z.
      • All numeric characters: 0 to 9.
      • The space character.
      • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
    • Optional options: ChannelMediaOptions

      @since v3.3.1. (Optional) The channel media options: ChannelMediaOptions.

    Returns Promise<void>

    • Void if the method call succeeds.
    • An error code if the method call fails. Possible errors include:
      • 1(Failed): A general error occurs (no specified reason).
      • 2(InvalidArgument): The parameter is invalid.
      • 5(Refused): The request is rejected, probably because the user is not an audience.
      • 7(NotInitialized): The SDK is not initialized.
      • 102(InvalidChannelId): The channel name is invalid.
      • 113(NotInChannel): The user is not in the channel.

takeSnapshot

  • takeSnapshot(channel: string, uid: number, filePath: string): Promise<void>
  • Takes a snapshot of a video stream.

    since

    v3.5.2

    This method takes a snapshot of a video stream from the specified user, generates a JPG image, and saves it to the specified path.

    The method is asynchronous, and the SDK has not taken the snapshot when the method call returns. After a successful method call, the SDK triggers the [SnapshotTaken]{@link RtcEvents.SnapshotTaken} callback to report whether the snapshot is successfully taken as well as the details of the snapshot taken.

    Note

    • Call this method after joining a channel.
    • If the video of the specified user is pre-processed, for example, added with watermarks or image enhancement effects, the generated snapshot also includes the pre-processing effects.

    Parameters

    • channel: string

      The channel name.

    • uid: number

      The user ID of the user. Set uid as 0 if you want to take a snapshot of the local user's video.

    • filePath: string

      The local path (including the filename extensions) for the snapshot. Ensure that the path you specify exists and is writable. For example:

      • On Android: /storage/emulated/0/Android/data/<package name>/files/example.jpg.
      • On iOS: /App Sandbox/Library/Caches/example.jpg.

    Returns Promise<void>

unloadEffect

  • unloadEffect(soundId: number): Promise<void>
  • Releases a specified preloaded audio effect from the memory.

    Parameters

    • soundId: number

      ID of the audio effect. Each audio effect has a unique ID.

    Returns Promise<void>

unregisterMediaMetadataObserver

  • unregisterMediaMetadataObserver(): Promise<void>
  • Unregisters the metadata observer.

    Returns Promise<void>

updateChannelMediaRelay

  • Updates the channels for media relay.

    After the channel media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call updateChannelMediaRelay.

    After a successful method call, the SDK triggers the ChannelMediaRelayEvent callback with the UpdateDestinationChannel(7) state code.

    Note

    • Call this method after the startChannelMediaRelay method to update the destination channel.

    • This method supports adding at most four destination channels in the relay. If there are already four destination channels in the relay.

    Parameters

    Returns Promise<void>

updateRtmpTranscoding

  • Updates the transcoding configuration.

    since

    v3.6.2

    After you start pushing media streams to CDN with transcoding, you can dynamically update the transcoding configuration according to the scenario. The SDK triggers the TranscodingUpdated callback after the transcoding configuration is updated.

    Parameters

    Returns Promise<void>

updateScreenCaptureParameters

Static create

  • Creates an RtcEngine instance.

    Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

    Note

    • You must create an RtcEngine instance before calling any other method.
    • The Agora React Native SDK supports creating only one RtcEngine instance for an app.

    Parameters

    • appId: string

      The App ID issued to you by Agora. See How to get the App ID. Only users in apps with the same App ID can join the same channel and communicate with each other. Use an App ID to create only one RtcEngine instance. To change your App ID, call destroy to destroy the current RtcEngine instance, and after destroy returns 0, call create to create an RtcEngine instance with the new App ID.

    Returns Promise<RtcEngine>

    • The RtcEngine instance, if the method call succeeds.
    • The error code, if the method call fails.
      • 101(InvalidAppId): The app ID is invalid. Check if it is in the correct format.

Static createWithAreaCode

  • Creates an RtcEngine instance.

    deprecated

    Deprecated as of v3.3.1. Use createWithContext instead.

    Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

    Note

    • You must create an RtcEngine instance before calling any other method.
    • The Agora React Native SDK supports creating only one RtcEngine instance for an app.

    Parameters

    • appId: string

      The App ID issued to you by Agora. See How to get the App ID. Only users in apps with the same App ID can join the same channel and communicate with each other. Use an App ID to create only one RtcEngine instance. To change your App ID, call destroy to destroy the current RtcEngine instance and after destroy returns 0, call create to create an RtcEngine instance with the new App ID.

    • areaCode: AreaCode

      The area of connection. This advanced feature applies to scenarios that have regional restrictions. For details, see AreaCode.

      After specifying the region, the app that integrates the Agora SDK connects to the Agora servers within that region.

    Returns Promise<RtcEngine>

    • The RtcEngine instance, if the method call succeeds.
    • The error code, if the method call fails.
      • 101(InvalidAppId): The app ID is invalid. Check if it is in the correct format.

Static createWithConfig

  • Creates an RtcEngine instance.

    deprecated

    Deprecated as of v3.4.5. Use createWithContext instead.

    since

    v3.3.1.

    Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

    Note

    • You must create an RtcEngine instance before calling any other method.
    • The Agora RTC Native SDK supports creating only one RtcEngine instance for an app for now.

    Parameters

    Returns Promise<RtcEngine>

    • The RtcEngine instance, if the method call succeeds.
    • The error code, if the method call fails.
      • 101(InvalidAppId): The app ID is invalid. Check if it is in the correct format.

Static createWithContext

  • Creates an RtcEngine instance.

    since

    v3.4.5

    Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

    Note

    • You must create an RtcEngine instance before calling any other method.
    • The Agora RTC Native SDK supports creating only one RtcEngine instance for an app for now.

    Parameters

    Returns Promise<RtcEngine>

    • The RtcEngine instance, if the method call succeeds.
    • The error code, if the method call fails.
      • 101(InvalidAppId): The app ID is invalid. Check if it is in the correct format.

Static getErrorDescription

  • getErrorDescription(error: number): Promise<string>
  • Gets the warning or error description.

    since

    v3.3.1.

    Parameters

    • error: number

      The warning or error code in Warning or Error.

    Returns Promise<string>

    The warning or error description.

Static getSdkVersion

  • getSdkVersion(): Promise<string>
  • Gets the SDK version.

    since

    v3.3.1.

    You can call this method either before or after joining a channel.

    Returns Promise<string>

    The version of the current SDK in the string format. For example, 2.3.0.

Static instance

  • Gets a created RtcEngine instance.

    Note

    Ensure that you have created an RtcEngine. Otherwise, the method call fails and the SDK returns an error message.

    Returns RtcEngine

    • The RtcEngine instance, if the method call succeeds.
    • Returns an error when it fails to get an RtcEngine.

Generated using TypeDoc