Book Image

Creating Mobile Apps with jQuery Mobile - Second Edition

By : Andy Matthews, Shane Gliser
Book Image

Creating Mobile Apps with jQuery Mobile - Second Edition

By: Andy Matthews, Shane Gliser

Overview of this book

<p>jQuery Mobile is a mobile-centric web framework developed by the jQuery team. The project focuses on building a framework compatible with the ever-increasing variety of smartphones and tablet computers on the market. The jQuery Mobile framework plays well with other frameworks and platforms, such as PhoneGap and Backbone.</p> <p>Automate repetitive tasks easily and painlessly with the Grunt task runner, build a fully responsive, gorgeous photography website, and learn how to mix and match jQuery Mobile 1.4.5 into existing websites and how to deploy those changes to content management systems such as WordPress, Drupal, and HarpJS. jQuery Mobile aims to reach everyone, and so does this book. It will enhance your mobile knowledge and help you to create versatile, unique sites quickly and easily.</p>
Table of Contents (18 chapters)
Creating Mobile Apps with jQuery Mobile Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling HTML5 Audio with JavaScript


Here's where things 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
  $currentAudio.data("playing",false)
    .data("progressBar", $page.find("input.progressBar")).data("progressThread",null);

  //loadstart and progress occur with autoload
  $currentAudio[0].addEventListener('loadstart', function(){ 
    //Fires when the browser starts looking
  ...