Note that there are some explanatory texts on larger screens.

plurals
  1. POAvfoundation - Play and record video (along with audio and preview) simultaneously
    primarykey
    data
    text
    <p>I am trying to record and play video simultaneously. Is this possible with avfoundation? Currently i am able to do it as long as i dont record audio. As soon as i add audio input to AVCaptureSession and restart the whole thing i receive "AVCaptureSessionWasInterruptedNotification" and recording stops. </p> <p>This is how i play video. </p> <pre><code>MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; [moviePlayer.view setFrame:self.playerView.bounds]; moviePlayer.useApplicationAudioSession=NO; self.player = moviePlayer; [moviePlayer release]; [self.playerView addSubview:player.view]; [player play]; </code></pre> <p>And this is how I record video:</p> <pre><code>NSError *error; AVCamCaptureManager *captureManager = [[AVCamCaptureManager alloc] init]; if ([captureManager setupSessionWithPreset:AVCaptureSessionPresetLow error:&amp;error]) { [self setCaptureManager:captureManager]; AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[captureManager session]]; self.captureVideoPreviewLayer= previewLayer; UIView *view = [self cameraView]; CALayer *viewLayer = [view layer]; [viewLayer setMasksToBounds:YES]; CGRect bounds = [view bounds]; [captureVideoPreviewLayer setFrame:bounds]; if ([captureVideoPreviewLayer isOrientationSupported]) [captureVideoPreviewLayer setOrientation:AVCaptureVideoOrientationPortrait]; [captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; [[captureManager session] startRunning]; [self setCaptureVideoPreviewLayer:captureVideoPreviewLayer]; if ([[captureManager session] isRunning]) { [captureManager setOrientation:AVCaptureVideoOrientationPortrait]; [captureManager setDelegate:self]; [viewLayer insertSublayer:captureVideoPreviewLayer below:[[viewLayer sublayers] objectAtIndex:0]]; NSString *countString = [[NSString alloc] initWithFormat:@"%d", [[AVCaptureDevice devices] count]]; NSLog(@"Device count: %@",countString); } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Failure" message:@"Failed to start session." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil]; [alertView show]; [alertView release]; } } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Input Device Init Failed" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil]; [alertView show]; [alertView release]; } [captureManager release]; if (![[self captureManager] isRecording]) { [[self captureManager] startRecording]; } </code></pre> <p>Where as i am using "AVCamCaptureManager" from apple AVCam sample code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload