While using iphone PhotoLibrary, Restrict user to select any video file more than duration of 60secs?

两盒软妹~` 提交于 2019-12-08 13:02:37

问题


Is there any method available to check video file duration as soon as user select Video from iPhone photo library ? And restrict user to select if that video file is more than 60secs


回答1:


imagePickerController.videoMaximumDuration = 60.0f; // limits video length to 60 seconds.

where imagePickerController is object of UIImagePickerController.

Using videoMaximumDuration method you can restrict length of video from both ways. Like if you are recording video an alert will popup saying you cannot record video more than 60 sec and if you are selecting any video file from your library, first it will check the length of your video if length is more than 60 sec. Again alert will popup saying video is larger than 60 sec but there will be two options i.e. use or cancel. If you select use then it will crop the length of video upto 60sec from the beginning.




回答2:


videoMaximumDuration method alert you as soon as 60 sec reached




回答3:


There is no way to filter assets using the UIImagePicker. However, using the new Asset Library Frameworks, you can fairly easily create your own video picker that filters videos based on your criteria.

For a good head start on doing this, here is a github repository that has recreated the UIImagePicker functionality using the Asset Library Frameworks: https://github.com/elc/ELCImagePickerController . You'll also want to look at the documentation for the ALAssetsFilter for setting up filter criteria.

Here is a video demoing the control: http://vimeo.com/15666311

And here is his blog where he talks a bit about the control: http://www.icodeblog.com/2010/10/07/cloning-uiimagepickercontroller-using-the-assets-library-framework/

Cheers!




回答4:


self.durationLabel.text = [NSString stringWithFormat:"Duration: %f",(float) self.player.duration]

And ultimately output:

self.durationLabel.text = [NSString stringWithFormat:@"Running Time: %d min",(int) ceil(self.player.duration/60)];



回答5:


From the IPhone SDK Application Development: Building Applications for the AppStore

You can also read the duration of the sample (in seconds) through the duration property. This, too, is represented as an NSTimeInterval, which is typed to a double floating-point:

NSTimeInterval duration = player.duration


来源:https://stackoverflow.com/questions/5799962/while-using-iphone-photolibrary-restrict-user-to-select-any-video-file-more-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!