spotify/ios-sdk

didChangePosition missing?

Closed this issue · 5 comments

johra commented

I could not find a way to have a playback timer in the app being updated, SPTAppRemotePlayerState has playbackPosition but this is not updated in real-time?

My case is to have the app change track after X seconds of playback.

cjam commented

I am also interested in knowing the position of the track. Ideally, I'd like to know when in the track a track was changed / stopped. I'm not sure the API supports that sort of thing at the moment.

+1 on needing a playback timer or some way to get current time from the currently playing track, essential of course for things like progress bars. I believe playbackPosition is specifically relating to what item in the player's queue is currently being played (i.e. track 4 of 15).

Slin commented

You can call getPlayerState on the playerAPI object, the returned player state has a playbackPosition.
I'm just calling it all the time and it's working ok.

It also tells you what track is playing. If the track changes from one call to another I assume that the last one ended and use it to stop playback (unless I know the player changed the song actively).

johra commented

Thanks @Slin. Unfortunately this does not work when the app goes to background and timers get disabled. And I need the track to fade automatically at certain intervals.

As @Slin pointed out you can achieve this by calling getPlayerState at a regular interval.

@johra If you can keep your app alive in the background your timers should still fire.