使用 UIImagePicker 类我可以选择 UIImagePickerControllerSource 作为 UIImagePickerControllerSourceTypeCamera。这将显示两个选项,相机以及录像机。
我只希望用户可以使用视频录制选项。一旦用户打开它就开始录制,而无需点击录制按钮。
谁知道这怎么可能?
谢谢
使用 UIImagePicker 类我可以选择 UIImagePickerControllerSource 作为 UIImagePickerControllerSourceTypeCamera。这将显示两个选项,相机以及录像机。
我只希望用户可以使用视频录制选项。一旦用户打开它就开始录制,而无需点击录制按钮。
谁知道这怎么可能?
谢谢
在 UIImagePickerController 上设置mediaTypes属性。
在你的 .h 文件中
#define MAX_VIDEO_DURATION 10
@interface VideoCaptureVC_iPhone : UIViewController
<UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
IBOutlet UIImageView *imageView;
UIImagePickerController *picker;
}
在你的 .m 文件中
- (void)viewDidLoad
{
// Create UIImagePickerController
picker = [[UIImagePickerController alloc] init];
picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
picker.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];
picker.videoMaximumDuration = MAX_VIDEO_DURATION;
// Set the source type to the camera
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
// Set ourself as delegate
[picker setDelegate:self];
// Always check to see if there is a front facing camera before forcing one on the picker
if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
[picker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
}
[picker setShowsCameraControls:NO];
[picker takePicture]
}