听歌结束 just_audio

Listening to Song End in just_audio

我想问一下,在 just_audio flutter package 中歌曲结束时是否有任何流可以收听,或者有什么方法可以做到这一点?

查看文档,AudioPlayer instances have a field called playerState or playerStateStream (If you want to listen for events). playerStateStream can be listened to using the stream which has a field called processingState. This field contains all the information you require (Here is the list)。如果处理状态完成,则播放器播放完毕。


示例:

_player.playerStateStream.listen((playerState) {
    if (playerState.processingState == ProcessingState.completed) {
        // Some Stuff
    }
});