voronianski / soundcloud-audio.js

:musical_note: SoundCloud tracks and playlists with HTML5 Audio API
http://caniuse.com/#feat=audio
284 stars 46 forks source link

Playlists #1

Closed scottwvw closed 9 years ago

scottwvw commented 9 years ago

Has anyone got an example of using this tool with playlists? The single example works great but I'm having trouble getting it to work with a playlist and pulling in the individual track data

voronianski commented 9 years ago

@scottwvw take a look at:

// to load PLAYLIST and resolve it's data
scPlayer.resolve('http://soundcloud.com/jxnblk/sets/yello', function (err, playlist) {
    // do smth with array of `playlist.tracks` or playlist's metadata
    // e.g. display playlist info in a view etc.
    console.log(playlist);

    // once playlist is loaded it can be played
    scPlayer.play();

    // for playlists it's possible to switch to another track in queue
    // e.g. we do it here when playing track is finished 
    scPlayer.on('ended', function () {
        scPlayer.next();
    });

    // play specific track from playlist by it's index
    scPlayer.play({playlistIndex: 2});
});

Maybe you have some specific question?