6

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."

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

iPhone: 5 seconds video capture

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 :)

Community
  • 1
  • 1
PotatoFro
  • 6,378
  • 4
  • 20
  • 22
  • 1
    I need the same thing...its ultimately going to be the difference between native and HTML5/PhoneGap. Their documentation (http://docs.phonegap.com/en/1.0.0/phonegap_media_capture_capture.md.html#CaptureVideoOptions) is HILARIOUS too. They show 3 parameters and for iOS NONE of them are supported :s – SomethingOn Aug 03 '12 at 19:05

1 Answers1

4

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

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...

Here's my solution:

 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);
SomethingOn
  • 9,813
  • 17
  • 68
  • 107