Skip to content

Instantly share code, notes, and snippets.

@LottieVixen
Forked from rctay/gist:9829266
Last active July 15, 2018 06:17
Show Gist options
  • Save LottieVixen/67ff0c61b47fd4462364ec7f247f7514 to your computer and use it in GitHub Desktop.
Save LottieVixen/67ff0c61b47fd4462364ec7f247f7514 to your computer and use it in GitHub Desktop.
shuffle/randomize playlist/set tracks in Soundcloud Widget eg. https://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites
require(["lib/play-manager"], function(a) {
// via http://stackoverflow.com/a/6274381
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]
function shuf(o) { for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); }
shuf(a.source.models);
var c = a.getCurrentSound(), p = c ? c.isPaused() : false;
a.playNext(); a.playPrev(); // poor man's refresh of current playing song
if (p) a.pause(c); // preserve first-run state
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment