代码改变世界

录像

2015-10-16 04:52  真实16  阅读(339)  评论(0编辑  收藏  举报

//

//  ViewController.m

//  UI-NO.22录像

//

//  Created by Bruce on 15/8/20.

//  Copyright (c) 2015年 Bruce. All rights reserved.

//

 

#import "ViewController.h"

#import <AVFoundation/AVFoundation.h>

#import <MobileCoreServices/MobileCoreServices.h>

 

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

//    UIImagePickerController  图像采取控制器

//    可以用来选取图片 拍照  录像

    

    UIImagePickerController *picker = [[UIImagePickerController alloc]init];

//    UIImagePickerControllerSourceTypePhotoLibrary, 图片库

//    UIImagePickerControllerSourceTypeCamera, 摄像头

//    UIImagePickerControllerSourceTypeSavedPhotosAlbum  相册

    picker.sourceType = UIImagePickerControllerSourceTypeCamera;

    picker.mediaTypes = @[(NSString *)kUTTypeMovie];

//    视频录制最大时长

    picker.videoMaximumDuration = 10;

//    录制视频的质量

    picker.videoQuality = UIImagePickerControllerQualityTypeLow;

//    是否显示摄像头控制面板

    picker.showsCameraControls = YES;

//    设置摄像头拍照或录像

    picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;

//    设置 前后摄像头

    picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

//    设置闪光灯的类型

    picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;

    

    [self presentViewController:picker animated:YES completion:nil];

    

//    拍照

//    [picker takePicture];

//    开始录像

    [picker startVideoCapture];

//    结束录像

    [picker stopVideoCapture];

    

//    完成操作

    //完成

//    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

@end