//js代码
function captureVideo() {
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 2});
}
//captureVideo方法执行失败后回调函数
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureSuccess(mediaFiles) {
var i, path,len;
alert(mediaFiles.length);
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
//对应的逻辑内容
// path = mediaFiles[i].fullPath;
uploadVideo(mediaFiles[i]);
}
}
function uploadVideo(mediaFile) {
var ft = new FileTransfer(), path = mediaFile.fullPath, name = mediaFile.name;
ft.onprogress = showUploadingProgress;
navigator.notification.progressStart("", "当前上传进度");
var options = new FileUploadOptions();
options.fileKey = "indexFile"; //文件的键值
options.fileName = path.substr(path.lastIndexOf('/') + 1); //文件名
options.mimeType = "multipart/form-data"; //MIME编码
options.chunkedMode = false;
var params = {};
params.value1 = "test";
params.value2 = "param";
options.params = params;
ft
.upload(
path,
encodeURI("http://192.168.1.105:8080/file/VideoUploadForIndex.action"),
function(result) {
console
.log('Upload success:'
+ result.responseCode);
console.lo
phonegap捕获视频上传
最新推荐文章于 2022-03-03 20:49:30 发布
本文介绍使用PhoneGap进行视频捕获并尝试上传的过程。目前上传功能尚未实现,期待对参数传递和值设置有经验的大神提供指导。在研究过程中,作者发现了JS代码的一些关键点。
摘要由CSDN通过智能技术生成