我正在尝试从一组歌曲创建临时播放列表并显示播放列表。出于某种原因,播放列表将在屏幕上随机遗漏一两首歌曲,有时它会完美运行。不知道为什么。
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) );
});
}