I’m developing for Spotify (JavaScript) on an OSX machine and the application crashes when I’m trying to play a song.
The call I make to the API is: player.play(trackURI);
What happens is that the Spotify client will play for about 1/4th of a second the song, then it will crash. I do believe it is this method that crashes the client as I have debugged it to this point.
If you need any other info, and have any clue about why this could happen, I’m looking forward to a reply.
More information:
So, I’ve managed to replicate it. What happens is that I have registered for the EVENT_CHANGE event like so player.observe(models.EVENT.CHANGE, function (e) {
When the song ends and a new one starts, I want to play the next song in my fake queue. Therefore, I call player.play(nextSongId) when the EVENT.CHANGE is triggered with e.data.curtrack == true.
Then I guess Spotify tries to play the next song in its queue, but then I want to play my own next song, so Spotify crashes.
After some fixing up, I think this happens because I was calling player.play(trackURI) almost immediately after I had called it once before. This happened because I was changing a song, which triggered the EVENT.CHANGE event, and then I would again call player.play() again. See the piece of code for a good way to deal with song changes.
Also, if you have a button called “Next song” or so, connect it to the
playNextSong()method:Seems like Spotify is not crashing anymore. Cheers!