FrontierPsychiatrist / node-spotify

A module for node.js to use libspotify.
MIT License
142 stars 20 forks source link

Playlist events don't appear to be working as they were #85

Closed stuarttayler closed 5 years ago

stuarttayler commented 9 years ago

I have an app that used the playlist object's 'tracksAdded' event. This used to register the tracks added whilst the app was running. However, now it appears that they are only being registered when the app first starts.

Has Spotify changed something? Or am I missing something?

var options = {
    appkeyFile: 'spotify_appkey.key',
    cacheFolder: 'cache',
    settingsFolder: 'settings'
};

var spotify = require('spotify')(options);

var ready = function() {
    console.log('ready');
    var myPlaylist = spotify.playlistContainer.getPlaylist(5);

    var track = myPlaylist.getTrack(1);
    spotify.player.play(track);

    myPlaylist.on({
        tracksAdded: function(err, playlist, newtracks, position) {
            console.log('track has been added');      
        }
    });
};

spotify.on({
    ready: ready
});

spotify.login('username', 'password', false, false);

process.on('SIGINT', function() {
  spotify.logout(); // clears events
  process.exit( );
});
stuarttayler commented 9 years ago

I've been playing around and for some reason this only happens on one particular playlist - the playlist that I've been experimenting with testing events on. All other playlists still fire events as normal. Is there a reason events would stop working with a particular playlist?

FrontierPsychiatrist commented 9 years ago

Hm, can't think of a reason. So the event is only firing directly after the startup but not while the program is running?

stuarttayler commented 9 years ago

Yes only directly after startup. When I call 'numTracks' on the playlist, it doesn't recognise the additional tracks either. Also, no other playlist events fire (tracksRemoved, playlistRenamed) after startup.

I have the same problem running on Mac OSX and my Raspberry Pi.

I have made the particular playlist public and collaborative. If you wanted to investigate, here's the URI: spotify:user:stuarttayler:playlist:48Nt9j5ox4Nhsa9tHylTgf

Thanks