Skip to content

Randomizing the Playlist

MikeWills edited this page Oct 12, 2012 · 6 revisions

You can randomize your playlist by doing the following:

bot.playlistAll(function(playlist) {
    var i = 0
    var reorder = setInterval(function() {
        if(i <= playlist.list.length) {
            var nextId = Math.ceil(Math.random() * playlist.list.length);
            bot.playlistReorder(i, nextId);
            console.log("Song " + i + " changed.");
            i++;
        } else {
            clearInterval(reorder);
            console.log("Reorder Ended");
            bot.speak("Reorder completed.");
        }
    }, 1000);
});

Clone this wiki locally