2014-02-22 74 views
0

我試圖從一組歌曲中創建臨時播放列表並顯示播放列表。出於某種原因,播放列表會在屏幕上隨機忽略一兩首歌,有時它完美地起作用。不知道爲什麼。Spotify API臨時播放列表無法正常工作

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)); 
    }); 
} 

回答

相關問題