video

Starting in iOS 3.0, you can record video, with included audio, on supported devices. To display the video recording interface, create and push a UIImagePickerController object, just as for displaying the still-camera interface.

To record video, you must first check that the camera source type (UIImagePickerControllerSourceTypeCamera) is available and that the movie media type (kUTTypeMovie) is available for the camera. Depending on the media types you assign to themediaTypes property, the picker can directly display the still camera or the video camera, or a selection interface that lets the user choose.

Using the UIImagePickerControllerDelegate protocol, register as a delegate of the image picker. Your delegate object receives a completed video recording by way of the imagePickerController:didFinishPickingMediaWithInfo: method.

On supported devices, you can also pick previously-recorded videos from a user’s photo library.

    

if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

    {

        UIImagePickerController  *pickerController = [[UIImagePickerControlleralloc]init];

        pickerController.sourceType =UIImagePickerControllerSourceTypeCamera;

//   + (NSArray *)availableMediaTypesForSourceType:(UIImagePickerControllerSourceType)sourceType;


        pickerController.mediaTypes = [NSArrayarrayWithObject:@"public.movie"];

        pickerController.cameraCaptureMode =UIImagePickerControllerCameraCaptureModeVideo;

        pickerController.delegate = self;

       [selfpresentViewController:pickerControlleranimated:YEScompletion:Nil];

    }

//  访问库中的视频

    if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

    {

        UIImagePickerController  *pickerController = [[UIImagePickerControlleralloc] init];

        pickerController.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;

        pickerController.mediaTypes = [NSArrayarrayWithObject:@"public.movie"];

        pickerController.delegate = self;

       [selfpresentViewController:pickerController animated:YEScompletion:Nil];

    }

 For information on trimming recorded videos, see UIVideoEditorController Class Reference and UIVideoEditorControllerDelegate Protocol Reference.

In iOS 4.0 and later, you can record from a device’s camera and display the incoming data live on screen. You useAVCaptureSession to manage data flow from inputs represented by AVCaptureInput objects (which mediate input from anAVCaptureDevice) to outputs represented by AVCaptureOutput.

In iOS 4.0 and later, you can edit, assemble, and compose video using existing assets or with new raw materials. Assets are represented by AVAsset, which you can inspect asynchronously for better performance. You use AVMutableComposition to compose media from one or more sources, then AVAssetExportSession to encode output of a composition for delivery.

Playing Video Files

OS supports the ability to play back video files directly from your application using the Media Player framework, described inMedia Player Framework Reference


Playing full-screen movies

-(void) playMovieAtURL: (NSURL*) theURL {
 
    MPMoviePlayerController* theMovie =
                [[MPMoviePlayerController alloc] initWithContentURL: theURL];
 
    theMovie.scalingMode = MPMovieScalingModeAspectFill;
    theMovie.movieControlMode = MPMovieControlModeHidden;
 
    // Register for the playback finished notification
    [[NSNotificationCenter defaultCenter]
                    addObserver: self
                       selector: @selector(myMovieFinishedCallback:)
                           name: MPMoviePlayerPlaybackDidFinishNotification
                         object: theMovie];
 
    // Movie playback is asynchronous, so this method returns immediately.
    [theMovie play];
}
 
// When the movie is done, release the controller.
-(void) myMovieFinishedCallback: (NSNotification*) aNotification
{
    MPMoviePlayerController* theMovie = [aNotification object];
 
    [[NSNotificationCenter defaultCenter]
                    removeObserver: self
                              name: MPMoviePlayerPlaybackDidFinishNotification
                            object: theMovie];
 
    // Release the movie instance created in playMovieAtURL:
    [theMovie release];
}

https://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MediaPlayer_Framework/_index.html#//apple_ref/doc/uid/TP40006952

Framework
/System/Library/Frameworks/MediaPlayer.framework
Header file directories
/System/Library/Frameworks/MediaPlayer.framework/Headers



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值