Book Image

PhoneGap Mobile Application Development Cookbook

By : Matt Gifford
Book Image

PhoneGap Mobile Application Development Cookbook

By: Matt Gifford

Overview of this book

<p>As more and more of our online life and daily activities evolve into the mobile landscape it has never been of more importance to start venturing into the world of mobile applications.<br />&nbsp;<br />With PhoneGap, you can put your existing development skills and HTML, CSS, and JavaScript knowledge to great use by creating mobile apps for cross-platform devices.<br /><br />"PhoneGap Mobile Application Development Cookbook" will show you how to create native mobile applications for multiple device platforms using the PhoneGap API. You will learn to build dynamic applications that interact with the native functionality on the device to create a rich, interactive experience for your users.<br /><br />This is a cookbook with each section written as a recipe in an informal, friendly style. Each recipe contains the complete code needed to build your applications, and plenty of screenshots showing the completed projects running on devices are included to assist you.<br /><br />"PhoneGap Mobile Application Development Cookbook" will introduce the PhoneGap API to you in clear, concise sections, breaking down each recipe to achieve realistic working projects that can be applied to your own mobile applications.<br /><br />You will be shown how to use the mobile development framework to build applications that can be deployed and run on multiple mobile platforms including iOS, Android, and BlackBerry.<br /><br />This book will explore the various methods and functions available using the API, and how to write code that interacts with the native functions, including geolocation sensors, contacts database, and native button events of the device to create powerful applications ready for the market place.<br /><br />"PhoneGap Mobile Application Development Cookbook" will help you break into the world of mobile application development. Build mobile applications in code you&rsquo;re comfortable with, create a richer user experience for your users and become part of the ever-growing mobile market place.</p>
Table of Contents (17 chapters)
PhoneGap Mobile Application Development Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Playing audio files from the local filesystem or over HTTP


The PhoneGap API provides us with a relatively straightforward process to play back audio files. These can be files stored within the application's local filesystem, bundled with the application, or over remote files accessible by a network connection. Wherever the files may be, the method of playback is achieved in exactly the same way.

How to do it...

We must create a new Media object and pass into it the location of the audio file we want to play back:

  1. Create the initial layout for the HTML, and include the relevant references to the JavaScript and style sheets. In this example we are going to be using the jQuery Mobile framework (http://jquerymobile.com/):

    <!DOCTYPE HTML>
    <html>
      <head>
        <meta name="viewport" content="width=screen.width; user-
    scalable=no" />
        <title>Audio Player</title>
        <link rel="stylesheet" href="jquery/jquery.mobile-1.1.1.min.css" type="text/css">
        <script...