临时播放列表的马赛克视图

时间:2013-04-13 12:47:29

标签: spotify

如果我创建临时播放列表,请手动添加曲目,然后尝试将其用作图像视图的来源:

var imageForPlaylist = imageView.forPlaylist(playlist, { height: 300, widht: 300 });

结果始终是占位符(quaver图像)。

这是预期的行为吗?

1 个答案:

答案 0 :(得分:2)

您应该看到马赛克图片。试试这段代码,生成一个包含10首曲目的临时播放列表:

(function () {
  "use strict";
  var sp = getSpotifyApi(),
    models = sp.require("$api/models"),
    views = sp.require("$api/views"),
    container = document.getElementById('container');

  var tempPlaylist = new models.Playlist();
  var playlistUri = 'spotify:user:nowplaylist:playlist:6QHyDeqaPNZ0nyLFJbSKTL';
  models.Playlist.fromURI(playlistUri, function (playlist) {
    for (var i = 0, l = Math.min(10, playlist.length); i < l; i++) {
      var track = playlist.get(i);
      tempPlaylist.add(track);
    }
  });

  var player = new views.Player();
  player.context = tempPlaylist;
  container.appendChild(player.node);
})();

并使用播放器呈现此Image

Player for a temporary playlist