2012-08-16 2 views
1

iPhone 4/4S 용 비밀번호 앱을 만들고 있습니다. 사용자가 비밀 번호를 3 번 ​​입력하면 실패한 아이폰의 전면 카메라를 사용하여 사용자의 영화를 만들고 싶습니다. 이것은 새로운 것은 아니지만 앱 스토어에있는 많은 앱이 비슷한 기능을합니다. 그 사람의 사진을 찍고 그의 GEO 좌표 등을 얻으십시오.비밀리에 UIImagePickerController를 사용하여 동영상을 녹화하십시오.

제가 직면 한 과제는 무비 촬영을 설정하려고 할 때 카메라 오버레이가 전체 화면을 차지한다는 것입니다. 내가 정말로하고 싶은 것은 사용자가 여전히 로그인 화면과 버튼을 보도록하지만 비밀리에 사용자의 영화를 녹화하고 만들 수있게하려는 것입니다. 내가 할 수있는 방법이 있니?

이것은 내가 사용하고있는 코드입니다. 내 *의하는 .m 파일

-(IBAction) makeMovieNow 
{ 
    picpicker = [[UIImagePickerController alloc] init]; 
     picpicker.delegate = self; 


     picpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     picpicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

     picpicker.showsCameraControls = NO; 
     picpicker.navigationBarHidden = YES; 
     picpicker.wantsFullScreenLayout = NO; 

     picpicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; 
     picpicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo; 

     picpicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff; 
     picpicker.cameraDevice = UIImagePickerControllerCameraDeviceFront; 

     picpicker.videoQuality = UIImagePickerControllerQualityTypeHigh; 

     picpicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; 

     //The problem is right here! 
     //picpicker.cameraViewTransform = CGAffineTransformScale(picpicker.cameraViewTransform, 0.01, 0.01); 
     [self presentModalViewController:picpicker animated:YES]; 

     [picpicker startVideoCapture]; 
} 

문제는 바로 여기에있다 "picpicker presentModalViewController"내 *의 .H 파일

@interface v1InstantController : UIViewController <UIImagePickerControllerDelegate> 
{ 
    UIImagePickerController *picpicker; 
} 

@property (nonatomic, retain) UIImagePickerController *picpicker; 

에서

. 이것을 사용할 때 Iris splash 등으로 카메라 화면을 시작하고 전체 화면에 무엇이 기록되는지 보여줍니다. cameraViewTransform을 사용하더라도 페이지의 아무 것도 사용할 수 없게되고이 카메라 오버레이를 페이지 중간에 배치합니다. (아주 작은 카메라 오버레이가 있음) 사용자가 녹음 중이라는 것을 알리고 그 사람이 평상시처럼 업무를 수행하길 바란다. 즉 페이지에 비밀번호를 잘못 입력하려고 계속합니다.

답변

0

다음은 미래에 관심이있는 사람을위한 답변입니다. 그것을 평가해라!

@synthesize session; 
@synthesize videoPath2; 

-(IBAction) makeMovieNow 
{ 

    NSLog(@"makeMovieNow .."); 

    //record movie 
    session = [[AVCaptureSession alloc] init]; 
    [session beginConfiguration]; 
    session.sessionPreset = AVCaptureSessionPresetHigh; 

    AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; 
    captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 


    NSError *error = nil; 
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
    device = [self frontFacingCameraIfAvailable]; 
    AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; 
    if (!videoInput) 
    { 
     // Handle the error appropriately. 
     NSLog(@"ERROR: trying to open camera: %@", error); 
    } 

    AVCaptureDevice *audioDevice  = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio]; 
    AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error ]; 


    AVCaptureMovieFileOutput *movieFileOutput = [[AVCaptureMovieFileOutput alloc] init]; 

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectoryPath = [paths objectAtIndex:0]; 
    NSString *movieFileName = [NSString stringWithFormat: @"Secret.mov"]; 
    NSString *fullPathToFile2 = [documentsDirectoryPath stringByAppendingPathComponent:movieFileName]; 
    NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:fullPathToFile2]; 

    videoPath2=[outputURL path]; 


    [session addInput:videoInput]; 
    [session addInput:audioInput]; 
    [session addOutput:movieFileOutput]; 
    [session commitConfiguration]; 

    //start recording 
    [session startRunning]; 
    [movieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self]; 
} 

-(IBAction) makeMovieStop 
{ 
    NSLog(@"makeMovieStop ..."); 

    //stop recording 
    [session stopRunning]; 

    //save video to photo-album 
    UISaveVideoAtPathToSavedPhotosAlbum(videoPath2, self, nil, nil); 

} 
5

UIImagePickerController는 많은 노력을 기울이지 않고도 사용자가 사진/비디오를 가져올 수있는 수단을 제공하므로 사용자가 항상 볼 수 있습니다.

더 많은 조정이 필요하므로 AVFoundation을 살펴볼 수 있습니다. Apple Documentation은 좋은 시작점을 제공해야합니다.

+0

당신은 어떤 작업을 예/샘플의 알고 있는지가 coreVideo을 포함하도록 확인하고 CoreMedia는 *를하는 ​​.m 파일에 * .H 파일

@interface v1InstantController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate> { AVCaptureSession *session; NSString *videoPath2; } @property (nonatomic, retain) AVCaptureSession *session; @property (nonatomic, retain) NSString *videoPath2; 

을 프레임 워크 암호? –

+0

몇 가지 샘플 프로젝트가 있습니다. 기본 사항은 [AVCam] (https://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112)입니다. , [SquareCam] (https://developer.apple.com/library/ios/#samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190)도 재미있을 수 있습니다. –

관련 문제