Controlling HTML5 Audio with JavaScript

Alright then, here we start to get a little bit more hairy with JavaScript.

First, let's set up an interval to update the progress bar. It's going to have to serve two functions, displaying the current time and changing the time. We'll start by adding references to these objects as well as placing event hooks for every one of the audio events that we might want to attach to. The comments describe which events are fired when:

//for every song page $(document).on("pagecreate", ".songPage", function(){ var $page = $(this); var $currentAudio = $page.find("audio"); //set references to the playing status, progress bar, and //progress interval on the audio object itself $"playing",false) .data("progressBar", ...

Get Creating Mobile Apps with jQuery Mobile now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.