错误域= AVFoundationErrorDomain代码= -11814"无法记录"

Akb*_*apu 8 record objective-c avfoundation ios

它不断给我错误:

错误域= AVFoundationErrorDomain代码= -11814"无法记录"

我不确定是什么问题?我想在拍摄照片后计数器达到1时正确录制声音.

static int counter;
//counter will always be zero it think unless it is assigned.


if (counter == 0){

dispatch_async([self sessionQueue], ^{
    // Update the orientation on the still image output video connection before capturing.
    [[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];

    // Flash set to Auto for Still Capture
    [AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];

    // Capture a still image.
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

        if (imageDataSampleBuffer)
        {//[AVCaptureSession snapStillImage];
            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
            UIImage *image = [[UIImage alloc] initWithData:imageData];
            [[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:nil];
        }
        NSLog(@"i");
    }];
});

    if (!_audioRecorder.recording)
{
   //start recording as part of still image

    _playButton.enabled = NO;
    _stopButton.enabled = YES;
    [_audioRecorder record];

    for(int i=0;i<1000;i++)
    {
        //do nothing just counting
    }

    //stop the recording
}

}

else if (counter == 1)

{
    [self recordForDuration:5];
}


}
Run Code Online (Sandbox Code Playgroud)

小智 7

此错误是因为您使用仿真器,需要使用设备

问候

  • 这发生在我的设备上。 (3认同)