PhoneGap / Cordova iOS:捕获持续时间限制的视频(即30秒) [英] PhoneGap/Cordova iOS: capture video with a duration limit (ie. 30 seconds)

查看:181
本文介绍了PhoneGap / Cordova iOS:捕获持续时间限制的视频(即30秒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制视频捕获到30秒。现在PhoneGap文档说明了以下iOS实现:

I would like to limit video capturing to 30 seconds. As of now the PhoneGap documentation says the following of iOS implementation:

持续时间参数不受支持,记录长度不能以编程方式限制。 >

"The duration parameter is not supported. Recording lengths cannot be limited programmatically."

我发现这个帖子似乎给一个纯客观的C实现的解决方案:

I did find this post which seems to give the solution for a purely objective C implementation:

a href =http://stackoverflow.com/questions/5838774/iphone-5-seconds-video-capture> iPhone:5秒视频捕获

iPhone: 5 seconds video capture

问题是:这是可以轻松地做成一个phonegap插件或有一些其他原因phonegap无法实现这一点吗?如果你认为它可以做 - 任何信息指向我正确的方向是非常感谢!感谢:)

The question is: Is this something that could "easily" be made into a phonegap plugin or is there some other reason phonegap hasn't been able to implement this? If you think it can be done - any information pointing me in the right direction is much appreciated! Thanks :)

推荐答案

我试图解决相同的问题,可能有一个解决方案:

I'm trying to solve the same problem and may have a solution:

capture.captureVideo( )函数返回 MediaFile 的数组对象。这些对象具有 MediaFile.getFormatData()方法,它告诉你文件的持续时间,因此你可以拒绝该文件,如果太长...

The capture.captureVideo() function returns an array of MediaFile objects. Those objects have a MediaFile.getFormatData() method that tells you what the duration of the file is and therefore you could reject the file if its too long...

这里是我的解决方案:

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

                mediaFiles[0].getFormatData(function(data) {

                    if(data.duration > 30) {
                        /* Tell the user the video is too long */
                    } else {
                        /* Video is less than the max duration...all good */
                    }
                });

        }, function(error) { /* An error occured */ },
null);

这篇关于PhoneGap / Cordova iOS:捕获持续时间限制的视频(即30秒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆