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:
Firstly, create a new PhoneGap project named
audiorecord
by running the following command:phonegap create audiorecord com.myapp.audiorecord audiorecord
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
plugin by running the following command:cordova plugin add org.apache.cordova.media-capture
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...