Skip to content

Instantly share code, notes, and snippets.

@imakewebthings
Created February 21, 2012 03:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imakewebthings/1873472 to your computer and use it in GitHub Desktop.
Save imakewebthings/1873472 to your computer and use it in GitHub Desktop.
Background audio for each slide in deck.js
/* Plays all audio elements inside a slide when the slide becomes active
and pauses them when the user navigates away. Replace pause with
whatever functionality desired (maybe pause and set currentTime to 0?) */
$(document).bind('deck.change', function(e, from, to) {
$.deck('getSlide', from).find('audio').each(function() {
this.pause && this.pause();
});
$.deck('getSlide', to).find('audio').each(function() {
this.play && this.play();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment