brim-borium/spotify_sdk

subscribePlayerState() duration property doesnt update.

Closed this issue · 5 comments

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
SpotifySdk.subscribePlayerState(), doesn't stream data. The progress not updating only updating when we click play/pause (state changes)

Expected behavior
Duration should update every ms or sec.

Desktop (please complete the following information):

  • OS: Android 10

Smartphone (please complete the following information):

  • Device: Xaomi mi 10 ultra

@kalismeras61 did you try the example app? Does it have the same behavior?

@fotiDim yes it is happening with example app

Hi!
I'm having the exact same problem on iOS (14.1), the playback position doesn't update by itself, we need to fire play/pause to get an update.
Any solution on how to solve this ?
Thanks !

Hi folks! This has not been a problem for me as the state still should continue in real time at same pace. Currently I store my references to a Song class, which has it's starting time, seek amount (when its play method was called) and length stored (among other things). In any moment of time I am able to compute the current playback position (some DateTime and Duration calculations involved), and listen to the Stream<PlayerState> to correct any changes in my Song instance.

That is then used by a Consumer to rebuild greater changes into widget tree as they actually happen (including recomputation of an AnimationController), and is further down connected to very small AnimatedBuilder which computes the width of a FractionallySizedBox representing the song progress bar.

If I wanted a time display, I'd just use the builder of said Consumer to make a Timer to the nearest full second in song duration, which would call a Timer.periodic with a value of one second to be very precise on my timing.

So in my experience, the Stream streams just enough data to be precise, if you can make the assumption that time runs forwards in similar fashion and scale in both Spotify app and your app.

Ping @kalismeras61 @Davidvision

This is not a bug in the Flutter Spotify SDK. This is identical to the behaviour of the underlying native SDKs. You can find a corresponding iOS SDK issue here. I encourage you to research the corresponding native SDKs before filing bugs.

As you understand we cannot offer this functionality in the Flutter Spotify SDK unless the native SDKs support it. You can follow @Hegezcc's suggestion as a potential workaround.