Spotify playback manager returns incorrect timeposition

81 Views Asked by At

When my iOS app plays a Spotify track that has not been off-lined, there is sometimes a short lag before play beings. The occasional delay in play is understandable. But the timeposition property on SPPlaybackManager starts advancing when the track is asked to play, rather than when the play begins. Therefore, if a track lags five seconds before play begins, the timeposition value is five seconds more than actual play. This causes a problem as my app uses the timeposition value to display info that corresponds with a specific spot in the song.

In case it makes a difference, I've adjusted the kTargetBufferLength value to allow crossfade. Could that effect the timeposition property?

Thanks in advance for any help on how to sync timeposition with actual playtime.

1

There are 1 best solutions below

0
On

What sort of offset are you seeing?

The playback position is only updated when audio data is delivered to Core Audio - see the AudioUnitRenderDelegateCallback() callback function in SPCoreAudioController. For checking this out in the debugger, that's the place to start.

It's also worth noting that many tracks have some silence at the beginning.