Magnar Myrtveit
Magnar Myrtveit

Reputation: 2760

Spotify Preview API: player.change event not fired on queued tracks

When playing from a playlist in Spotify, if I queue a track from somewhere else than the playlist currently playing (for example from a search result), the player's change event is not fired when the queued track starts playing.

Are anyone else experiencing this? Is the change event only supposed to be fired within the playing context? If so, how do I get track info when playing queued tracks?

Upvotes: 0

Views: 249

Answers (2)

Mr Jones
Mr Jones

Reputation: 1198

I know this is a little old, but for reference, you should be able to do something like this:

models.player.addEventListener('change', updateCurrentTrack);

function updateCurrentTrack(){
    models.player.load('track').done(function (player) {
        if(player.track.uri != currentTrack.uri){
            currentTrack = player.track;
            //enter code here
        }
    }
}

Upvotes: 0

Matthias Grafe
Matthias Grafe

Reputation: 13

What did you do?

Try something like this:

    models.player.addEventListener('change:track', updateCurrentTrack);

Upvotes: 0

Related Questions