preload method
@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}.
Implementation
FutureOr<int> preload(int effectId, NSString filePath) async {
return await nativeCall('preload:filePath:', [effectId, filePath]);
}