1
votes

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

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?

1
Works fine when I'm creating a playlist with one single track (the one I want to play) and then playing the playlist instead. But thats not too good because I also want the user to continue listening to the other songs in the album.Kristoffer Svanmark
You want to play a specific track, but you don't want it to play? Do you want to queue the track and set the album as the current playlist?tobias_

1 Answers

2
votes

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