startRhythmPlayer

Enables the virtual metronome.

virtual int startRhythmPlayer(const char* sound1, const char* sound2, const AgoraRhythmPlayerConfig& config) = 0;
Deprecated
Deprecated since v4.6.0.

After enabling the virtual metronome, the SDK starts playing the specified sound effect files from the beginning and controls the duration of each file based on the beatsPerMinute you set in AgoraRhythmPlayerConfig. For example, if you set beatsPerMinute 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 metronome sound 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
The absolute path or URL of the strong beat sound effect file (including file extension). For example, C:\music\audio.mp4. See SDK supported formats for supported audio file formats.
sound2
The absolute path or URL of the weak beat sound effect file (including file extension). For example, C:\music\audio.mp4. See SDK supported formats for supported audio file formats.
config
Metronome configuration. See AgoraRhythmPlayerConfig.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -22: Sound effect file not found. Please set the correct paths for sound1 and sound2.