loop method
Future<AudioPlayer>
loop(
- String fileName, {
- double volume = 1.0,
- bool? isNotification,
- PlayerMode mode = PlayerMode.MEDIA_PLAYER,
- bool stayAwake = false,
Like play, but loops the audio (starts over once finished).
The instance of AudioPlayer
created is returned, so you can use it to stop the playback as desired.
isNotification and stayAwake are not implemented on macOS.
Implementation
Future<AudioPlayer> loop(
String fileName, {
double volume = 1.0,
bool? isNotification,
PlayerMode mode = PlayerMode.MEDIA_PLAYER,
bool stayAwake = false,
}) async {
final url = await load(fileName);
final player = _player(mode);
await player.setReleaseMode(ReleaseMode.LOOP);
await player.play(
url.toString(),
volume: volume,
respectSilence: isNotification ?? respectSilence,
stayAwake: stayAwake,
);
return player;
}