audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

onPlayerCompletion is getting called twice

Open akshayru opened this issue 4 years ago • 4 comments

1 - Start Playlist from First Song. 2 - On Song complete it triggers OnPlayerCompletion. 3 - OnPlayerCompletion will call next song in index. 4 - By the time Future call is getting complete the onPLayerCompletion again gets called. 5 - This causes skipping 1 song, i tried adding state check but it always return as completed as the earlier play call is not yet finished.

akshayru avatar Jul 23 '20 00:07 akshayru

Finally found a workaround. Below is my code, based on duration i am blocking second call after onPlayerCompletion. Let me know your thoughts if this approach has any side effect or impact?

audioPlayer.onPlayerCompletion.listen((event) { setState(() { if ((duration.inSeconds >= position.inSeconds) && position.inSeconds > 0) {

akshayru avatar Jul 24 '20 21:07 akshayru

What is duration and Position? Not work well in my case.

shinewanna avatar Sep 01 '20 10:09 shinewanna

What is duration and Position? Not work well in my case.

Duration is the entire length in time of the song while position is the current time of the song which is playing, usually returned by onAudioPositionChanged

muarachmann avatar Nov 10 '20 02:11 muarachmann

On which platforms do you experience this? Can you check, is this still a thing with 1.x.x? Thx :)

Gustl22 avatar Sep 03 '22 10:09 Gustl22

Closing as stale.

Gustl22 avatar Nov 03 '22 08:11 Gustl22