Closed gmatiastor closed 4 years ago
That particular stream updates whenever the playback state changes, whenever the buffering state changes, and whenever the icy metadata changes. So if the icy metadata changes but the playback state stays the same, you will still get a new event emitted on that stream.
If you're only interested in the playback state, you can listen directly to AudioPlayer.playbackStateStream
. If you're interested in both the playback state and the buffering state, there is currently no stream that combines those two, but you can select any combination of streams you want using rxdart:
newStream = Rx.combineLatest2(AudioPlayer.playbackStateStream, AudioPlayer.bufferingStream,
(state, buffering) => BufferPlaybackState(state, buffering));
BufferPlaybackState
doesn't exist, but you could invent your own class to encapsulate this set of data.
Originally, FullAudioPlaybackState
just contained the playback state and buffering state, and I guess the icy metadata field was added in a PR. I can see it would still be useful to add a stream without the icy metadata, and this may come in a future release, but in the meantime you can still listen to the streams for the individual pieces of data you want and combine them with rxdart.
Thank you very much!!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.
Hello,
I'm sure you can guide me to the right solution in this issue. Thanks in advance.
Which API doesn't behave as documented, and how does it misbehave? fullPlaybackStateStream.listen()
Possible error: fullPlaybackStateStream streams duplicated events . In particular, two similar events with "completed" stated are streamed , triggering twice the code I need to execute only once when playback is finished.
Minimal reproduction project
Expected behavior Only one event is expected per state (connecting, stop, playing, completed)
Smartphone (please complete the following information): Android emulator
Flutter SDK version
Additional context Add any other context about the problem here.