Spotify应用API:从相册播放特定曲目 [英] Spotify App API: Play specific track from album
问题描述
试图从与播放器视图中查看相册播放特定的曲目。
它使用时的工作都好
Trying to play a specific track from an album with the player view. It works all good when using
player.play(objTrack, objTrack.album);
但我不想要的歌曲自动播放,所以我使用:
But I don't want the song to autoplay, so I'm using:
player.track = objTrack;
player.context = objTrack.album;
但是,当我这样做,无论是它不会在所有的工作,否则将开始播放该专辑的第一首曲目无论哪个跟踪我设置。
But when I do so, either it won't work at all or it will start playing the first track of the album regardless which track I set.
我怎样才能使这项工作? :/
谢谢你。
How can I make this work? :/ Thanks.
这不会做的伎俩无论是。
目前,我想要这个方法:
This does not do the trick either. I'm currently trying this method:
var album = m.Album.fromURI('spotify:album:7Kmmw7Z5D2UD5MVwdm10sT', function(album) {
var player = new v.Player();
player.track = album.get(3);
player.context = album;
document.body.appendChild(player.node);
});
但是,这不会获取并播放曲目编号3,它将发挥专辑的第一首曲目。如果这张专辑只包含1的轨道,它将会崩溃。任何想法?
But this will not fetch and play track number 3, it will play the first track of the album. And if the album only contains 1 track, it will crash. Any ideas?
推荐答案
如果您在当前曲目编号,我想你从一个轨道的对象得到它。这里是我的方式:
If you have the current track number I suppose you got it from a track object. Here is my way:
// trackObj <- The track object
var album = m.Album.fromURI('spotify:album:7Kmmw7Z5D2UD5MVwdm10sT', function(album) {
var player = new v.Player();
player.track = trackObj;
album.get = function() {
return trackObj;
}
player.context = album;
document.body.appendChild(player.node);
});
这篇关于Spotify应用API:从相册播放特定曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!