Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Recording audio within your application


The PhoneGap API provides us with the ability to record audio directly within our application, bypassing the native audio recording application.

How to do it...

We will use the Media object to create a reference to an audio file in which we'll record the audio data:

  1. Firstly, create a new PhoneGap project named audioapi by running this line:

    phonegap create audioapi com.myapp.audioapi audioapi
    
  2. Add the device's platform. You can choose to use Android, iOS, or both:

    cordova platform add ios
    cordova platform add android
    
  3. Add the media-capture plugins by running this line:

    cordova plugin add org.apache.cordova.media
    
  4. Open www/index.html. Let's clean up the unnecessary elements. We will use jQuery Mobile, so we have to make a reference:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <meta name="format-detection" content="telephone=no" />
            <meta name="msapplication-tap-highlight" content="no" ...