5

に問題がありAVCaptureSession startRunningます。IOS 7 を搭載した iPhone 5 でのみ問題があります。私のアプリはビデオを録画しAVCaptureVideoPreviewLayer、すべてを表示する必要がありますが、iPhone 5 でテストすると、初回呼び出しエラー = AVErrorMediaServicesWereReset. これは私のコードで、capturemanager を作成しますstartRunning

    -(void)startVideoTranslation{   
    CGRect r = videoBackView.bounds;

    videoPreviewView = [[UIView alloc] initWithFrame:r];
    [videoBackView addSubview:videoPreviewView];

    if (currentGameType == MPGameTypeCrocodile){
        if (captureManager == nil) {
            captureManager = [[AVCamCaptureManager alloc] init];

            [captureManager setDelegate:self];
            if ([captureManager setupSession]) {
                //Create video preview layer and add it to the UI

                AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[captureManager session]];
                CALayer *viewLayer = [videoPreviewView layer];
                [viewLayer setMasksToBounds:YES];

                CGRect bounds = [videoPreviewView bounds];
                bounds.origin.y = bounds.origin.y+1;
                [newCaptureVideoPreviewLayer setFrame:bounds];

                if ([newCaptureVideoPreviewLayer.connection isVideoOrientationSupported]) {
                    [newCaptureVideoPreviewLayer.connection setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];
                }

                [newCaptureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

                [viewLayer insertSublayer:newCaptureVideoPreviewLayer below:[[viewLayer sublayers] objectAtIndex:0]];

                captureVideoPreviewLayer = newCaptureVideoPreviewLayer;


                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isErrorSession:) name:AVCaptureSessionRuntimeErrorNotification object:nil];
                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
                        [[captureManager session] startRunning];
                    });
            }
        }
    }

}

そして、私がここで呼び出すこのセレクター:

-(void)showPrepareView{
[self playSound:@"start"];

BGView.frame = videoBackView.bounds;

[prepareView addSubview:videoBackView];
[self startVideoTranslation];
[videoBackView addSubview:BGView];

このコードでは、 で使用AVAudioPlayerします。[self playSound:]videobackViewPreviewLayer

この問題の理由を知っている人はいますか?

今、私はこの問題を解決したので、-(id)initWithFrame に移動します:

captureManager = [[AVCamCaptureManager alloc] init];
[captureManager setDelegate:self]
[captureManager setupSession];
[[captureManager session] startRunning];

しかし、私はそれが何であるかを理解していません。

4

0 に答える 0