O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required