是否支持在phonegap(cordova)中捕获带声音的视频?

时间:2013-10-16 10:32:08

标签: ios objective-c cordova phonegap-plugins

是否支持在phonegap(cordova)中捕获带声音的视频? 我在我的iPad上检查了一个带有视频捕获的phonegap 3.1应用程序,并且没有录制视频的录音

欣赏帮助 感谢

function uploadFile(mediaFile) {
        var ft = new FileTransfer(),
            path = mediaFile.fullPath,
            name = mediaFile.name;

        ft.upload(path,
            "http://www/api/up_video",
            function(result) {
                cordova.logger.log('Upload success: ' + result.responseCode);
                cordova.logger.log(result.bytesSent + ' bytes sent');
            },
            function(error) {
                cordova.logger.log('Error uploading file ' + path + ': ' + error.code);
            },
            { fileName: name });
}


// capture callback
var captureSuccess = function(mediaFiles) {
    var i, path, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        path = mediaFiles[i].fullPath;
        name = mediaFiles[i].name;
        // do something interesting with the file
        alert(name);
        //alert(mediaFiles[i].size);
        //alert(mediaFiles[i].type);
        uploadFile(mediaFiles[i]);
    }
};

// capture error callback
var captureError = function(error) {
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error'); 
    cordova.logger.log( error); 
};

  navigator.device.capture.captureVideo(captureSuccess, captureError, {duration:6});

1 个答案:

答案 0 :(得分:1)

绝对。可以使用Phonegap的“Capture”API捕获视频和声音。请参阅文档here

根据评论进行编辑:

您永远不会告诉设备捕获音频。视频和音频的捕获是不同的操作。您还需要调用navigator.device.capture.captureAudio函数。请参阅here