preload abstract method

Future<int?> preload(
  1. int effectId, {
  2. required String filePath,
})

Preloads specified music files into memory to avoid repeated loading when playing the same file frequently and reduce CPU usage.

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 RTCAudioEffectPlayer.start 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 RTCAudioEffectPlayerEventHandler.onAudioEffectPlayerStateChanged.
After calling this API to preload A.mp3, if you need to call RTCAudioEffectPlayer.start to play B.mp3 with the same ID, please call RTCAudioEffectPlayer.unload to unload A.mp3 first, otherwise SDK will report an error "loadConflict".

filePath: The filepath of effect file. URL of online file, URI of local file, full path to local file, or path to local files starting with /assets/ are supported. For URL of online file, only the https protocol is supported.
The length of the pre-loaded file must not exceed 20s.
Audio effect file formats supported are the same as RTCAudioEffectPlayer.start.

Return value:

  • 0: Success.
  • <0: Failure.

Notes:

  • This API just preloads the specified audio effect file, and only calls the RTCAudioEffectPlayer.start API to start playing the specified audio effect file.
  • The specified audio effect file preloaded by calling this API can be unloaded by RTCAudioEffectPlayer.unload.

Implementation

Future<int?> preload(
  int effectId, {
  required String filePath,
});