Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
phonegap 2.8捕获视频时长在android 4.2.2中始终返回0_Android_Cordova - Fatal编程技术网

phonegap 2.8捕获视频时长在android 4.2.2中始终返回0

phonegap 2.8捕获视频时长在android 4.2.2中始终返回0,android,cordova,Android,Cordova,当我尝试在android 4.2.2(nexus 4)中获取捕获视频的持续时间时,我使用phonegap 2.8.1是否始终返回0?为什么我在几个设备上进行了测试,除了安卓4.2.2之外,其他设备都正常工作,然后我将phonegap版本改为2.7,然后也出现了同样的问题 navigator.device.capture.captureVideo(function(mediaFiles){ var i, len; for (i = 0, len = mediaFile

当我尝试在android 4.2.2(nexus 4)中获取捕获视频的持续时间时,我使用phonegap 2.8.1是否始终返回0?为什么我在几个设备上进行了测试,除了安卓4.2.2之外,其他设备都正常工作,然后我将phonegap版本改为2.7,然后也出现了同样的问题

 navigator.device.capture.captureVideo(function(mediaFiles){

      var i, len;

      for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        //uploadFile(mediaFiles[i]);
                    var mediaFile = mediaFiles[i];
                                          console.log(mediaFile.fullPath);


                                        mediaFile.getFormatData(
                                                                function(f){
                                                                var length= Math.ceil(f.duration);

                                                                  if(length > 60){


                                                                  navigator.notification.alert("Video Capture Limit exceeded Max limit 60 sec");
                                                                  } else {

                                                                                        $('.upBtn').show('1000');
                                                                  $('#startNow').text('Capture Again');
                                                                  var videoNode = document.querySelector('video');
                                                                  videoNode.src = fullTempPath;
                                                                $('#time').html("Dutration of Video == " + vidLength +" sec" );

                                                                  } 
                                                                },
                                                                function(){
                                                                navigator.notification.alert("Try Again..");

                                                                }
                                                                );




      }


      }, function(e){

       navigator.notification.alert("Try Again.. Camera Error" + e);




      }, {duration: 10000});
navigator.device.capture.captureVideo(函数(媒体文件){
变量i,len;
对于(i=0,len=mediaFiles.length;i60){
navigator.notification.alert(“视频捕获限制超过最大限制60秒”);
}否则{
$('.upBtn').show('1000');
$('#startNow').text('再次捕获');
var videoNode=document.querySelector('video');
videoNode.src=fullTempPath;
$('#time').html(“视频传输=”+vidLength+“秒”);
} 
},
函数(){
navigator.notification.alert(“重试…”);
}
);
}
},功能(e){
navigator.notification.alert(“重试..摄像机错误”+e);
},{持续时间:10000});

我自己也在尝试!但是为什么不使用

{duration: 60}
当你打电话的时候

navigator.device.capture.captureVideo(function(mediaFiles)
改成

navigator.device.capture.captureVideo(function(mediaFiles), {duration: 60}
这来自phonegap 2.7版本中的api。持续时间设置了录制持续时间的限制。代码必须更改以适应这种方式。它应该是支持的,我不能让它在我的开发手机上工作,但它根据phonegap组工作。希望这有帮助