I am trying to create a temporary playlist from a set of songs and display the playlist. For some reason, the playlist will randomly leave out a song or two on the screen and sometimes it works perfectly. No idea why.
var SortSongsMakeList = function(data)
{
SortSongs(data);
document.querySelector('h1').innerHTML = "";
models.Playlist.createTemporary('Server Songs').done(function(playlist)
{
playlist.load('tracks').done(function(loadedPlaylist)
{
for(var i = 0; i < data.length; i++)
{
loadedPlaylist.tracks.add(models.Track.fromURI(data[i].song_uri));
}
});
var newList = List.forPlaylist(playlist);
document.querySelector('h1').appendChild(newList.node);
newList.init();
playlist.tracks.clear();
// Remove the temporary ones not in use to reduce resource load
models.Playlist.removeTemporary( models.Playlist.fromURI(playlist.uri) );
});
}
您最好一次用一个数组设置所有轨道,例如此答案: https : //stackoverflow.com/a/21053309/9970
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.