playEffect abstract method

Future<void> playEffect(
  1. int soundId,
  2. String filePath,
  3. int loopCount,
  4. double pitch,
  5. double pan,
  6. int gain,
  7. bool publish, [
  8. int? startPos,
])

Plays the specified local or online audio effect file. To play multiple audio effect files at the same time, call this method multiple times with different soundId and filePath. For the best user experience, Agora recommends playing no more than three audio effect files at the same time. After the playback of an audio effect file completes, the SDK triggers the audioEffectFinished callback. Call this method after joining a channel.

Param soundId The audio effect ID. The ID of each audio effect file is unique. If you have preloaded an audio effect into memory by calling preloadEffect , ensure that this parameter is set to the same value as soundId in preloadEffect.

Param filePath The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: Android: /sdcard/emulated/0/audio.mp4, iOS: /var/mobile/Containers/Data/audio.mp4. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. See supported audio formats. If you have preloaded an audio effect into memory by calling preloadEffect , ensure that this parameter is set to the same value as filePath in preloadEffect.

Param loopCount The number of times the audio effect loops: ≥ 0: The number of playback times. For example, 1 means loop one time, which means play the audio effect two times in total. -1: Play the music effect in an infinite loop.

Param pitch The pitch of the audio effect. The value range is 0.5 to 2.0. The default value is 1.0, which means the original pitch. The lower the value, the lower the pitch.

Param pan The spatial position of the audio effect. The value range is 1 to10000. -1.0: The audio effect displays to the left. 0.0: The audio effect displays ahead. 1.0: The audio effect displays to the right.

Param gain The volume of the audio effect. The value range is 1 to10000. The default value is 100.0, which means the original volume. The smaller the value, the lower the volume.

Param publish Whether to publish the audio effect to the remote users. true: Publish the audio effect to the remote users. Both the local user and remote users can hear the audio effect. false: Do not publish the audio effect to the remote users. Only the local user can hear the audio effect.

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

Implementation

Future<void> playEffect(int soundId, String filePath, int loopCount,
    double pitch, double pan, int gain, bool publish,
    [int? startPos]);