ByteRTCAudioEffectPlayer class

Inheritance
  • Object
  • NativeClass
  • ByteRTCAudioEffectPlayer

Constructors

ByteRTCAudioEffectPlayer([NativeClassOptions? options])

Properties

$resource → NativeResource
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
ready Future<void>
Whether the instance is initialized
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

destroy() → void
inherited
getDuration(int effectId) FutureOr<int>
@detail api @brief Get the duration of the audio effect file. @param effectId Audio effect ID @return - >0: Success, the duration of the audio effect file in milliseconds. - < 0: failed. @note Call this API after start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}.
getPosition(int effectId) FutureOr<int>
@detail api @brief Gets the current position of audio effect file playback. @param effectId Audio effect ID @return - >0: Success, the current progress of audio effect file playback in milliseconds. - < 0: Failure. @note - When playing online files, calling this API may cause a delay in playback. - Call this API after start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}.
getVolume(int effectId) FutureOr<int>
@detail api @brief Gets the current volume. @param effectId Audio effect ID @return - >0: Success, the current volume value. - < 0: Failed. @note Call this API after start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}.
nativeCall<T>(String method, [List? args, NativeMethodMeta? meta]) Future<T>
Call instance method
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause(int effectId) FutureOr<int>
@detail api @brief Pauses the playback of audio effect files. @param effectId Audio effect ID @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - After calling start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} to start playing the audio effect file, you can pause the audio effect file by calling this API. - After calling this API to pause the audio effect file, you can call the resume:{@link #ByteRTCAudioEffectPlayer#resume} API to resume playback.
pauseAll() FutureOr<int>
@detail api @brief Pauses the Playback of all audio effect files. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - After calling the start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} API to start playing audio effect files, you can pause playing all audio effect files by calling this API. - After calling this API to pause the playback of all audio effect files, you can call the resumeAll{@link #ByteRTCAudioEffectPlayer#resumeAll} API to resume all playback.
preload(int effectId, NSString filePath) FutureOr<int>
@detail api @brief Preloads specified music files into memory to avoid repeated loading when playing the same file frequently and reduce CPU usage. @param effectId Audio effect ID。Used for identifying the audio effect. Please ensure that the audio effect ID is unique.
If this API is called repeatedly with the same ID, the later one will overwrite the previous one.
If you call start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} first and then call this API with the same ID, the SDK will stop the previous effect and then load the next one, and you will receive onAudioEffectPlayerStateChanged:state:error:{@link #ByteRTCAudioEffectPlayerEventHandler#onAudioEffectPlayerStateChanged:state:error}.
After calling this API to preload A.mp3, if you need to call start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} to play B.mp3 with the same ID, please call unload:{@link #ByteRTCAudioEffectPlayer#unload} to unload A.mp3 first, otherwise SDK will report an error AUDIO_MIXING_ERROR_LOAD_CONFLICT. @param filePath The filepath of effect file. URI or absolute path of a local file.
The length of the pre-loaded file must not exceed 20s.
Audio effect file formats supported are the same as start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - This API just preloads the specified audio effect file, and only calls the start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} API to start playing the specified audio effect file. - The specified audio effect file preloaded by calling this API can be unloaded by unload:{@link #ByteRTCAudioEffectPlayer#unload}.
resume(int effectId) FutureOr<int>
@detail api @brief Resumes the playback of audio effect files. @param effectId Audio effect ID @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note After calling the pause:{@link #ByteRTCAudioEffectPlayer#pause} API to pause the audio effect file, you can resume playback by calling this API.
resumeAll() FutureOr<int>
@detail api @brief Resumes the playback of all audio effect files. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note After calling the pauseAll{@link #ByteRTCAudioEffectPlayer#pauseAll} API to pause all the audio effect files being played, you can resume playback by calling this API.
sendInstanceGet<T>(String property) Future<T>
Get instance property
inherited
sendInstancePropertiesGet(dynamic nativeClass) Future<Map<String, dynamic>>
Get instance properties
inherited
sendInstanceSet(String property, dynamic value) Future<void>
Set instance property
inherited
setEventHandler(id<ByteRTCAudioEffectPlayerEventHandler> handler) FutureOr<int>
@detail api @brief Set the event handler. @param handler See ByteRTCAudioEffectPlayerEventHandler{@link #ByteRTCAudioEffectPlayerEventHandler}. @return - 0: Success. - < 0: Failed.
setPosition(int effectId, int position) FutureOr<int>
@detail api @brief Sets the start position of the audio effect file. @param effectId Audio effect ID @param position The starting playback position of the audio effect file in milliseconds.
You can get the total duration of the audio effect file by calling getDuration:{@link #ByteRTCAudioEffectPlayer#getDuration}, the value of position should be less than the total duration of the audio effect file. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - When playing online files, calling this API may cause a delay in playback. - Call this API after start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}.
setVolume(int effectId, int volume) FutureOr<int>
@detail api @brief Adjusts the volume level of a specified audio effect, including audio effect file and PCM effect. @param effectId Audio effect ID @param volume The ratio of the volume to the original volume in % with overflow protection. The range is [0, 400] and the recommended range is [0, 100]. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note Call this API after start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config}.
setVolumeAll(int volume) FutureOr<int>
@detail api @brief Sets the volume of all audio effect, including audio effect files and PCM effects. @param volume The ratio of the volume to the original volume in % with overflow protection. The range is [0, 400] and the recommended range is [0, 100]. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note This API has a lower priority than setVolume:volume:{@link #ByteRTCAudioEffectPlayer#setVolume:volume}, i.e. the volume of the audio effect set by setVolume is not affected by this API.
start(int effectId, NSString filePath, ByteRTCAudioEffectPlayerConfig config) FutureOr<int>
@detail api @brief Starts to play the audio effect file.
This API can be called multiple times with different IDs and filepaths for multiple effects at the same time. @param effectId Audio effect ID. Used for identifying the audio effect, please ensure that the audio effect ID is unique.
If this API is called repeatedly with the same ID, the previous effect will stop and the next effect will start, and you'll receive onAudioEffectPlayerStateChanged:state:error:{@link #ByteRTCAudioEffectPlayerEventHandler#onAudioEffectPlayerStateChanged:state:error}. @param filePath Audio effect file paths.
URL of online file, URI of local file, or full path to local file are supported. For URL of online file, only the https protocol is supported.
Recommended sample rate for audio effect files: 8KHz、16KHz、22.05KHz、44.1KHz、48KHz.
Local audio effect file formats supported by different platforms:
stop(int effectId) FutureOr<int>
@detail api @brief Stops the playback of audio effect files. @param effectId Audio effect ID @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - After calling the start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} API to start playing the audio effect file, you can call this API to stop playing the audio effect file. - After calling this API to stop playing an audio effect file, the audio effect file will be unloaded automatically.
stopAll() FutureOr<int>
@detail api @brief Stops playback of all audio effect files. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note - After calling start:filePath:config:{@link #ByteRTCAudioEffectPlayer#start:filePath:config} to start playing audio effect files, you can call this API to stop playing all audio effect files. - After calling this API to stop playing all audio effect files, the audio effect files will be unloaded automatically.
toString() String
A string representation of this object.
inherited
unload(int effectId) FutureOr<int>
@detail api @author zhangyuanyuan.0101 @brief Unloads the specified audio effect file. @param effectId Audio effect ID. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note After calling this method, regarding the current mixing state, if setEventHandler:{@link #ByteRTCAudioEffectPlayer#setEventHandler} is set, you will receive the onAudioEffectPlayerStateChanged callback.
unloadAll() FutureOr<int>
@detail api @author zhangyuanyuan.0101 @brief Unloads all audio effect files. @return - 0: Success. - < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details. @note After calling this method, regarding the current mixing state, if setEventHandler:{@link #ByteRTCAudioEffectPlayer#setEventHandler} is set, you will receive the onAudioEffectPlayerStateChanged callback.
updateResource(NativeResource resource) → void
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

codegen_$namespace → dynamic
no setter