how to play track from certain position using spotify apps API
-
26-10-2019 - |
Question
I am developing spotify third party application using javascript API. I am trying to play the track from certain position. I am having following code,
player.position = 50000; player.play(track);
But this code plays track from begining. I want to play the track from certain position. Is there any way to play track from certain position? Thanks.
Solution
You can also link directly to a specific position in a track by adding #1:31
to the end of a URI, for example spotify:track:3iDK8BAaBUatPR84gdfa9g#0:15
.
OTHER TIPS
You need to play the track first, then as soon as playback starts seek to the location you want.
You can observe when playback starts by adding an observer for models.EVENT.CHANGE
to the player object and looking at the playing
property.