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

Capturing audio using the device audio recording application


PhoneGap, through the Cordova media-capture plugin API, gives developers the ability to interact with the audio recording application on their device and save the recorded audio file for later use.

How to do it...

We'll make use of the Capture object and the captureAudio method of the media plugin API. The method will invoke the native device audio recording application to record our audio:

  1. Firstly, create a new PhoneGap project named audiorecord by running the following command:

    phonegap create audiorecord com.myapp.audiorecord audiorecord
    
  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 plugin by running the following command:

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