Reputation: 23
The old spotify API provided the playlist.add(track) method, whereas i can not find this method in the new 1.0 API
Is there a possible walkaround to add a track to an existing playlist?
Upvotes: 1
Views: 1115
Reputation: 4830
You can add a track to an existing playlist like so. Remember that you'll need to load tracks first, otherwise the tracks won't be on the playlist object.
require(['$api/models'], function(models) {
models.Playlist.fromURI('spotify:user:thelinmichael:playlist:4GiqW15bSO7K6MLFVRVh4z').load('tracks').done(function(playlist) {
track = models.Track.fromURI("spotify:track:3fllpI9uZKkdy3NJS0J1oV");
playlist.tracks.add(track);
});
});
Read more about the Collection class here.
Upvotes: 4