ryanheise / just_audio

Audio Player
1.06k stars 681 forks source link

playerStateStream not changing playing state after playlist is completed #1328

Open rphm opened 2 months ago

rphm commented 2 months ago

Which API doesn't behave as documented, and how does it misbehave?

The playerStateStream in the just_audio package is not updating the playing state to false after a playlist has completed. It remains true even though the processingStateis correctly set to ProcessingState.completed.

Minimal reproduction project

The example

To Reproduce (i.e. user steps, not code)

1) Run the example_playlist.dart example with break point at line 364 (Commit: b5fad794dee004a9cb92804fce6fcb12d025a0f8) 3) Select the last item in the playlist. 4) Wait for the item to complete playback. 5) Observe that the playerStateStream shows playing=true and processingState=ProcessingState.completed.

Error messages

No errors

Expected behavior After the last item in a playlist completes playback, the playerStateStream should update to show playing=false and processingState=ProcessingState.completed

Desktop (please complete the following information):

Smartphone (please complete the following information):

Flutter SDK version

[√] Flutter (Channel stable, 3.24.2)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
rphm commented 2 months ago

783

rphm commented 2 months ago

If I call pause manually like this, the playerState is set back to false as expected

_audioPlayer.playerStateStream.listen((playerState) async {
        print('playerState: ${playerState.toString()}');
        if(playerState.processingState == ProcessingState.completed) {
          await _audioPlayer.pause();
        }
});
I/flutter (19434): playerState: playing=true,processingState=ProcessingState.completed
I/flutter (19434): playerState: playing=false,processingState=ProcessingState.completed