关于如何在iOs中录制视频的基本描述4 [英] Basic description on how to record video in iOs 4

查看:90
本文介绍了关于如何在iOs中录制视频的基本描述4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我很好奇,如果有人能给我一个非常简短的描述如何在iOs 4中制作应用程序录制视频。我知道如何使用使用UIImagePickerController的os 3方法做所有媒体和什么但是我不知道iOs4是否仍然可以使用,如果没有,有人可以给我一个关于如何使用新方法做一个非常简短的描述吗? (不需要代码,但非常受欢迎。)

Hey guys i was curious if anybody could give me a very brief description of how to make an app record video in iOs 4. I know how to do all the media and whatnot using the os 3 method of using the UIImagePickerController but I do not know if that is still available in iOs4 and if not, could someone please give me a very brief description on how to do it using the new method? (No code required, but is more than welcome.)

- 谢谢!

推荐答案

这很简单。

我刚刚在界面上用一个按钮制作了一个基于视图的应用来测试它。按钮的动作是 - (IBAction)shootButtonPressed;

I just made a view-based app with a single button on the interface to test this. The button's action is - (IBAction)shootButtonPressed;

您必须检查设备是否支持视频录制,然后将图像选择控制器配置为只拍摄视频。此代码仅适用于实际设备。

You have to check if the device supports video recording and then configure the image picker controller to only shoot video. This code will only work on an actual device.

在主视图控制器头中,我使其符合两个协议: UIImagePickerControllerDelegate和UINavigationControllerDelegate

In the main view controller header, I made it conform to two protocols: UIImagePickerControllerDelegate and UINavigationControllerDelegate

然后我实现了这样的按钮按下方法;

Then I implemented the button press method like this;

- (IBAction)shootButtonPressed;
{
    BOOL canShootVideo = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

    if (canShootVideo) {
        UIImagePickerController *videoRecorder = [[UIImagePickerController alloc] init];
        videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
        videoRecorder.delegate = self;

        NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        NSArray *videoMediaTypesOnly = [mediaTypes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];
        BOOL movieOutputPossible = (videoMediaTypesOnly != nil);

        if (movieOutputPossible) {
            videoRecorder.mediaTypes = videoMediaTypesOnly;

            [self presentModalViewController:videoRecorder animated:YES];           
        }
        [videoRecorder release];
    }
} 

您还必须实施另外两种方法来处理电影的拍摄和放大选择并在用户取消摄像机选择器时。

You also have to implement two more methods to handle when a movie's shot & chosen and when the user cancels the video camera picker.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self dismissModalViewControllerAnimated:YES];

    // save the movie or something here, pretty much the same as doing a photo
    NSLog(@"movie captured %@", info);
}  

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    // process the cancellation of movie picker here
    NSLog(@"Capture cancelled");
}

超级简单。

有关详细信息,请参阅多媒体编程指南 - >关于音频和视频 - >使用视频 - >录制和编辑视频。它出现在Apple Docs中,虽然我的口味有些分散。

For more details, see the Multimedia Programming Guide --> About Audio and Video --> Using Video --> Recording and Editing Video. It's in the Apple Docs, although a little scattered for my taste.

这篇关于关于如何在iOs中录制视频的基本描述4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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