startRhythmPlayer
Enables the virtual metronome.
public abstract int startRhythmPlayer(String sound1, String sound2, AgoraRhythmPlayerConfig config);
After enabling the virtual metronome, the SDK plays the specified sound effect files from the beginning and controls the playback duration of each file according to the beatsPerMinute set in AgoraRhythmPlayerConfig. For example, if beatsPerMinute is set to 60, the SDK plays one beat per second. If the file duration exceeds the beat duration, the SDK only plays the audio content within the beat duration.
By default, the sound of the virtual metronome is published in the channel. If you want remote users to hear the sound, set publishRhythmPlayerTrack to true in ChannelMediaOptions.
Scenario
In scenarios such as music education and sports training, instructors often use a metronome to help students practice at the correct tempo. A measure consists of strong and weak beats, with the first beat of each measure being the strong beat and the rest being weak beats.
Timing
This method can be called before or after joining a channel.
Parameters
- sound1
- Absolute path or URL of the strong beat sound effect file (including file extension). For example: content://com.android.providers.media.documents/document/audio%203A14441. For supported audio formats, see [What audio formats does Agora RTC SDK support](https://doc.shengwang.cn/faq/general-product-inquiry/audio-format).
- sound2
- Absolute path or URL of the weak beat sound effect file (including file extension). For example: content://com.android.providers.media.documents/document/audio%203A14441. For supported audio formats, see [What audio formats does Agora RTC SDK support](https://doc.shengwang.cn/faq/general-product-inquiry/audio-format).
- config
- Metronome configuration. See AgoraRhythmPlayerConfig.
Return Values
- 0: Success.
- < 0: Failure.
- -22: Sound effect file not found. Please set the correct path for
sound1andsound2.
- -22: Sound effect file not found. Please set the correct path for