media-capture plugin needed.
Install it with this:
phonegap plugin add org.apache.cordova.media-capture
Here is my example.html(within javascript code).
This provides capability to start default system application for audio recording/reproducing and save your audio registration into default locale location(displaying it into a javascript alert):
<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Capture Audio Example Page</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Called when capture operation is finished
//
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
alert (mediaFiles[i].fullPath + " e " + mediaFiles[i].name);
}
}
// Called if something bad happens.
//
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureAudio() {
// Launch device audio recording application,
// allowing user to capture up to 2 audio clips
navigator.device.capture.captureAudio(captureSuccess, captureError, {limit: 2});
}
</script>
</head>
<body>
<button onclick="captureAudio();">Capture Audio</button> <br>
</body>
</html>
No comments:
Post a Comment