Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

control next and previous tracks in the soundcloud custom player

View gist:1509934
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
function getNextTrack(node) {
var $player = $(node).closest('.sc-player'),
$nextItem = $('.sc-trackslist li.active', $player).next('li');
// try to find the next track in other player
if(!$nextItem.length){
$nextItem = $player.nextAll('div.sc-player:first').find('.sc-trackslist li:first');
}
return $nextItem;
};
 
function getPrevTrack(node) {
var $player = $(node).closest('.sc-player'),
$prevItem = $('.sc-trackslist li.active', $player).prev('li');
// try to find the next track in other player
if(!$prevItem.length){
$prevItem = $player.prevAll('div.sc-player:first').find('.sc-trackslist li:last');
}
return $prevItem;
};
 
 
$(document).bind('onPlayerTrackFinish', function(event) {
var $nextItem = getNextTrack(event.target);
// init the next track but don't play :)
$nextItem.click().click();
});

That's what I needed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.