Skip to content

Instantly share code, notes, and snippets.

@Kuzcoo
Last active December 11, 2015 16:27
Show Gist options
  • Save Kuzcoo/f1ff1e1bd77993c54240 to your computer and use it in GitHub Desktop.
Save Kuzcoo/f1ff1e1bd77993c54240 to your computer and use it in GitHub Desktop.
Snippets to play with

Snippet

On this site, on the music part you can listen a track maintaining your click on it. Below some snippets to play with this opportunity. :-)

edit : actually it may not be intended, it works with Safari.

// or just basic version
$('.playToggle').click(function (e) { $(this).trigger({type: 'mousedown'}); });
// play one of the three playable song
var playSong = function (songNumber) {
if (songNumber > 2 || songNumber < 0) { return; }
$('.playToggle')
.eq(songNumber-1)
.trigger({type: 'mousedown'});
};
// play a random song whenever moving the mouse
window.onmousemove = function () {
playSong(Math.round(Math.random() *3));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment