Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AVAudioSession *audioSession = [AVAudioSession sharedInstance];
- NSError *setCategoryError = nil;
- [audioSession setActive:YES error:&setCategoryError];
- [audioSession setCategory:AVAudioSessionCategoryPlayback
- error:&setCategoryError];
- _mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviepath]];
- _mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
- _mpviewController.moviePlayer.controlStyle = MPMovieControlStyleNone;
- [_mpviewController.moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
- _mpviewController.moviePlayer.shouldAutoplay = YES;
- [_mpviewController.moviePlayer prepareToPlay];
- _mpviewController.view.frame = CGRectMake(0, 0, _screenWidth, _screenHeight);
- [self addSubview:_mpviewController.view];
- [_session beginConfiguration];
- [_session setSessionPreset: AVCaptureSessionPreset640x480];
- AVCaptureDevice * videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
- BOOL lock = [videoDevice lockForConfiguration:&error];
- if(lock) videoDevice.focusMode = AVCaptureFocusModeContinuousAutoFocus;
- [videoDevice unlockForConfiguration];
- if(videoDevice == nil){
- assert(0);
- }
- AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
- if(error){
- assert(0);
- }
- [_session addInput:input];
- AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
- AVCaptureDeviceInput * audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:nil];
- if(audioInput != nil) {
- [_session addInput:audioInput];
- }
- [_session commitConfiguration];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement