-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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