2014-06-12 12 views
5

Nó vẫn tiếp tục đem lại cho tôi những lỗi:Lỗi miền = AVFoundationErrorDomain Mã = -11.814 "Không thể Ghi"

Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Record"

Tôi không chắc chắn vấn đề là gì? Tôi đang cố ghi lại âm thanh ngay khi bộ đếm đạt đến 1 sau khi chụp ảnh.

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]; 
} 


} 
+3

Điều này có sử dụng trình mô phỏng không? –

+0

@MarkMcCorkle, gotcha! –

+0

có nó đã được sử dụng một mô phỏng! – Akbapu

Trả lời

2

lỗi này là do bạn sử dụng một emulator, bạn cần sử dụng một thiết bị

Trân

+1

Chạy trên thiết bị mang lại cho tôi lỗi chính xác này ... – pojomx

+0

Chạy trên thiết bị đã sửa lỗi cho tôi – Akbapu

1

Có thiết bị của bạn hạn chế việc truy cập máy ảnh dưới "Settings> General> Restrictions" cũng sẽ cung cấp cho bạn này lỗi.

Các vấn đề liên quan