Skip to content

@mataspetrikas /gist:1509934
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
control next and previous tracks in the soundcloud custom player
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();
});
@baptistebriel

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.