Skip to content

Instantly share code, notes, and snippets.

@mataspetrikas
Created April 20, 2011 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mataspetrikas/930612 to your computer and use it in GitHub Desktop.
Save mataspetrikas/930612 to your computer and use it in GitHub Desktop.
activate tracks without playing in the SoundCloud custom player
// add this after the '.sc-trackslist li' click listener
$(document).bind('activateTrack', function(event) {
var $track = $(event.target),
$player = $track.closest('.sc-player'),
trackId = $track.data('sc-track').id;
updateTrackInfo($player, trackId);
$track.addClass('active').siblings('li').removeClass('active');
$('.artworks li', $player).each(function(index) {
$(this).toggleClass('active', index === trackId);
});
});
// and then in your script trigger the custom event on the particular items
$(yourselected item).trigger('activateTrack');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment