PhoneGap: playback upload audio

September 5, 2011
By

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

// Called when capture operation is finished
//
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}

// Called if something bad happens.
//
function captureError(error) {
var msg = ‘An error occurred during capture: ‘ + error.code;
navigator.notification.alert(msg, null, ‘Uh oh!’);
}

// A button will call this function
//
function captureAudio() {
// Launch device audio recording application,
// allowing user to capture up to 2 audio clips
navigator.device.capture.captureAudio(captureSuccess,
captureError, {limit: 2});
}

// Upload files to server
function uploadFile(mediaFile) {
var path = mediaFile.fullPath,
name = mediaFile.name;

var media = new Media(mediaFile.fullPath);
media.play();
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*