Robert Strobl
Robert Strobl

Reputation: 325

Is there any event fired when a track gets starred or unstarred in the Spotify JavaScript API?

Is there any event fired when track gets starred or unstarred in the Spotify JavaScript API? If yes, how can I define a callback for this?

Upvotes: 0

Views: 138

Answers (1)

iKenndac
iKenndac

Reputation: 18776

You need to watch the starred playlist for item changes:

var sp = getSpotifyApi();
var models = sp.require('$api/models');

var playlist = models.library.starredPlaylist;
playlist.observe(models.EVENT.ITEMS_ADDED, function() {
  console.log('New starred tracks!');
  console.log(playlist.tracks);
});

Upvotes: 2

Related Questions