Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. AVAudioSession *audioSession = [AVAudioSession sharedInstance];
  2. NSError *setCategoryError = nil;
  3. [audioSession setActive:YES error:&setCategoryError];
  4. [audioSession setCategory:AVAudioSessionCategoryPlayback
  5. error:&setCategoryError];
  6.  
  7. _mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviepath]];
  8.  
  9. _mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
  10. _mpviewController.moviePlayer.controlStyle = MPMovieControlStyleNone;
  11. [_mpviewController.moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
  12.  
  13. _mpviewController.moviePlayer.shouldAutoplay = YES;
  14.  
  15. [_mpviewController.moviePlayer prepareToPlay];
  16.  
  17. _mpviewController.view.frame = CGRectMake(0, 0, _screenWidth, _screenHeight);
  18.  
  19. [self addSubview:_mpviewController.view];
  20.  
  21. [_session beginConfiguration];
  22.  
  23. [_session setSessionPreset: AVCaptureSessionPreset640x480];
  24.  
  25. AVCaptureDevice * videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  26. BOOL lock = [videoDevice lockForConfiguration:&error];
  27. if(lock) videoDevice.focusMode = AVCaptureFocusModeContinuousAutoFocus;
  28. [videoDevice unlockForConfiguration];
  29.  
  30. if(videoDevice == nil){
  31. assert(0);
  32. }
  33.  
  34. AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
  35. if(error){
  36. assert(0);
  37. }
  38.  
  39. [_session addInput:input];
  40.  
  41. AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
  42. AVCaptureDeviceInput * audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:nil];
  43. if(audioInput != nil) {
  44. [_session addInput:audioInput];
  45. }
  46.  
  47. [_session commitConfiguration];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement