How can I play a list of (short) audio one by one using audioplayers?
I now have the following code:
AudioPlayer? _player;
void _play(number) async {
_player?.dispose();
final player = _player = AudioPlayer();
print("trying to play number $number");
player.play(AssetSource('audio/$number.wav'));
}
...
void _playList(list) async{
for (int i=0;i<list.length;i++){
_play(i);
}
}
But because I am creating multiple AudioPlayer objects here, the audios got played simultaneously.
What I want to achieve is: Play the first audio, wait until it reaches the end, then play the next audio. Loop until all the audios in the list got played.