The PhoneGap API provides us with the ability to record audio directly within our application, bypassing the native audio recording application.
We will use the Media
object to create a reference to an audio file in which we'll record the audio data:
Firstly, create a new PhoneGap project named
audioapi
by running this line:phonegap create audioapi com.myapp.audioapi audioapi
Add the device's platform. You can choose to use Android, iOS, or both:
cordova platform add ios cordova platform add android
Add the
media-capture
plugins by running this line:cordova plugin add org.apache.cordova.media
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" ...