2013-08-21 66 views
0

我試圖通過創建API的Spotify一個臨時的播放列表與此代碼的臨時播放列表:Spotify的API - 創建

var playlist = models.Playlist.createTemporary("My temporary playlist"); 
models.Playlist.createTemporary("My temporary playlist").load('tracks').done(function(playlist) { 
    playlist.tracks.add(models.Track.fromURI("spotify:track:4VqPOruhp5EdPBeR92t6lQ")); 
    playlist.tracks.add(models.Track.fromURI("spotify:track:5HF5PRNJ8KGtbzNPPc93tG")); 
}); 

var list = List.forPlaylist(playlist); 
document.getElementById('playlistContainer').appendChild(list.node); 
list.init(); 

但我發現了以下錯誤:

core.js:4 - Uncaught TypeError: Object #<Promise> has no method 'load' 

任何想法我做錯了什麼?謝謝。

回答

3

我找到了解決辦法,仍然不知道爲什麼這個工作和我以前的代碼沒有,但你去那裏:

models.Playlist.createTemporary(playlist_name).done(function(playlist) { 
    playlist.load('tracks').done(function(loadedPlaylist) { 
    loadedPlaylist.tracks.add(models.Track.fromURI("spotify:track:4VqPOruhp5EdPBeR92t6lQ")); 
    loadedPlaylist.tracks.add(models.Track.fromURI("spotify:track:5HF5PRNJ8KGtbzNPPc93tG")); 
    }); 

    var list = List.forPlaylist(playlist); 
    document.getElementById('playlistContainer').appendChild(list.node); 
    list.init(); 
});