0

I have a simple spotify (JS) app and I want to either:

  • Create a new playlist with the first track and play it, or
  • Append the song to the currently playing playlist

     var playlist = new models.Playlist();
    
     ...
    
     var search = new models.Search(query);
    
     search.observe(models.EVENT.CHANGE, function() {
        if (search.tracks.length) {
          var track = search.tracks[0];
          playlist.add(track);
          if (!models.player.playing) 
             models.player.play(track, playlist);
        }     
      });
    
      search.appendNext(); 
    

Shouldn't this simply append the new track to the existing playlist? (playlist is scoped higher up, and it is definitely not re-created each time).

Currently nothing happens when a track is playing.

4

1 回答 1

1

它确实有效,但播放列表视图需要很长时间才能呈现为更新。(尽管它会立即附加曲目 - 点击下一步可以看到)。但是,正如评论中所提到的,它在使用名称创建时不会播放播放列表,只会播放临时的并因此具有 URI 的播放列表。

于 2012-06-27T03:50:26.100 回答