1
votes

I'm trying to play a song from a position other than the beginning of the track.

I've found that player.position = X will work as a standalone function, such as triggered by a button, but triggering it on player.observe(models.EVENT.CHANGE... results in a crash.

I figure this is because the track hasn't actually started playing once the event occurs as the player.position may still be at the previous song's position.

I've also experimented with sp.trackPlayer.seek() which seems to give the same results.

So has anyone got a song to start playing at another position than 0? (Or made the playhead jump ahead after the event of playing a new song?)

1

1 Answers

5
votes

Add the position after the uri, for example:

var uri= 'spotify:track:xxxxxx#02:04'

player.playTrackFromUri(uri)

See this sourcecode if you want inspiration:

https://github.com/Iteam1337/Wejay/blob/master/javascript/room.js