Skip to content

Instantly share code, notes, and snippets.

@vlazzle
Created September 22, 2011 00:52
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 vlazzle/1233760 to your computer and use it in GitHub Desktop.
Save vlazzle/1233760 to your computer and use it in GitHub Desktop.
Bookmarklet to play a SoundCloud track in loop
// note: currently, this only works for an individual track, e.g. the main track on
// http://soundcloud.com/tall-cans/el-pico-acoustic-ratatat-cover
//
// bookmarklet:
// (function($)%20{var%20$play%20=%20$(%27.controls%20a.play:first%27),poll%20=%20true;function%20startPolling()%20{setInterval(function()%20{if%20(poll)%20{if%20(!$play.hasClass(%27playing%27))%20{$play.trigger(%27click%27,%20true);}}},%20500);}$play.bind(%27click%27,%20function(e,%20loop)%20{if%20(typeof%20loop%20===%20%27undefined%27%20||%20!loop)%20{poll%20=%20!$play.hasClass(%27playing%27);}});startPolling();}(jQuery));
(function($) {
var $play = $('.controls a.play:first'),
poll = true;
function startPolling() {
setInterval(function() {
if (poll) {
if (!$play.hasClass('playing')) {
$play.trigger('click', true);
}
}
}, 500);
}
$play.bind('click', function(e, loop) {
if (typeof loop === 'undefined' || !loop) {
poll = !$play.hasClass('playing');
}
});
startPolling();
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment