简体   繁体   English

iPhone:基于计时器的录像?

[英]iPhone:Video recording based on timer?

I have implemented the code to do video recording feature. 我已经实现了执行视频录制功能的代码。 It works fine on 3GS device. 在3GS装置上运作正常。 I want to restrict the video recording based on some timer setting. 我想基于某些计时器设置来限制视频录制。 Lets say, i want to allow user to do video recording only upto 20 seconds or 35 seconds like that. 可以说,我想允许用户像这样最多进行20秒或35秒的视频录制。 How can i do that? 我怎样才能做到这一点? Can i show the timer kind of control on top of media player while recording the video? 录制视频时,我可以在媒体播放器顶部显示计时器类控件吗?

Please suggest me. 请给我建议。

Here is my code for video recording: 这是我的视频录制代码:

    UIImagePickerController *pickerController = 
                       [[[UIImagePickerController alloc] init] autorelease];
    pickerController.delegate = self;
    pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    pickerController.showsCameraControls = YES;
    pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
    [self presentModalViewController:pickerController animated:YES];

videoMaximumDuration expects an NSTimeInterval , which is a tpyedef for a float value. videoMaximumDuration需要一个NSTimeInterval ,它是一个float值的tpyedef。 So you should pass it a float value. 因此,您应该为它传递一个浮点值。 Try it like this: 像这样尝试:

UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
pickerController.delegate = self;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.showsCameraControls = YES;
pickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; // kUTTypeMovie is actually an NSString.
pickerController.videoMaximumDuration = 30.0f; // limits video length to 30 seconds.
[self presentModalViewController:pickerController animated:YES];
[pickerController release];

UIImagePickerController class has property videoMaximumDuration which works for NSTimeInterval . UIImagePickerController类具有属性videoMaximumDuration ,可用于NSTimeInterval

By default it's value is set for 10 minutes but you can change it's float value according to your need. 默认情况下,它的值设置为10分钟,但您可以根据需要更改其浮点值

So if you make object of UIImagePickerController class named videoPickerController then you can set timer for capturing video like- 因此,如果您将UIImagePickerController类的对象命名为videoPickerController则可以设置计时器以捕获视频,例如-

videoPickerController.videoMaximumDuration = 25.0f;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM