startRhythmPlayer method

  1. @override
Future<void> startRhythmPlayer(
  1. String sound1,
  2. String sound2,
  3. RhythmPlayerConfig config
)

Enables the virtual metronome.

Since v3.4.2

In music education, physical education, and other scenarios, teachers often need to use a metronome so that students can practice at the correct tempo. A meter is composed of a downbeat and some number of upbeats (including zero). The first beat of each measure is called the downbeat, and the rest are called the upbeats. In this method, you need to set the paths of the upbeat and downbeat files, the number of beats per measure, the tempo, and whether to send the sound of the metronome to remote users.

Note

  • After enabling the virtual metronome, the SDK plays the specified files from the beginning and controls the beat duration according to the value of beatsPerMinute in RhythmPlayerConfig. If the file duration exceeds the beat duration, the SDK only plays the audio within the beat duration.

Parameter sound1 The absolute path or URL address (including the filename extensions) of the file for the downbeat. For example: /sdcard/emulated/0/audio.mp4 on Android and /var/mobile/Containers/Data/audio.mp4 on iOS. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP.

Parameter sound2 The absolute path or URL address (including the filename extensions) of the file for the upbeats. For example: /sdcard/emulated/0/audio.mp4 on Android and /var/mobile/Containers/Data/audio.mp4 on iOS. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP.

Parameter config The metronome configuration. See RhythmPlayerConfig.

Implementation

@override
Future<void> startRhythmPlayer(
    String sound1, String sound2, RhythmPlayerConfig config) {
  return _invokeMethod('startRhythmPlayer', {
    'sound1': sound1,
    'sound2': sound2,
    'config': config.toJson(),
  });
}