playEffect abstract method
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. To achieve the optimal user experience, Agora recommends that you do not playing more than three audio files at the same time.
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 the value of this parameter is the same as that of soundId in preloadEffect.filePath
The file path. The SDK supports URLs and absolute path of local files. The absolute path needs to be accurate to the file name and extension. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. If you have preloaded an audio effect into memory by calling preloadEffect, ensure that the value of this parameter is the same as that of filePath in preloadEffect.loopCount
The number of times the audio effect loops. ≥ 0: The number of playback times. For example, 1 means looping one time, which means playing the audio effect two times in total. -1: Play the audio file in an infinite loop.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.pan
The spatial position of the audio effect. The value ranges between -1.0 and 1.0: -1.0: The audio effect is heard on the left of the user. 0.0: The audio effect is heard in front of the user. 1.0: The audio effect is heard on the right of the user.gain
The volume of the audio effect. The value range is 0.0 to 100.0. The default value is 100.0, which means the original volume. The smaller the value, the lower the volume.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.startPos
The playback position (ms) of the audio effect file.
Returns When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown. You need to catch the exception and handle it accordingly. < 0: Failure.
Implementation
Future<void> playEffect(
{required int soundId,
required String filePath,
required int loopCount,
required double pitch,
required double pan,
required int gain,
bool publish = false,
int startPos = 0});