如何在ios应用程序中暂停视频录制(objective-c)

时间:2017-06-06 11:43:46

标签: ios objective-c avfoundation avcam

使用AVCam我可以开始和停止视频录制。 这种方法开始录制:

-(void)captureOutput:(AVCaptureFileOutput *)captureOutput didStartRecordingToOutputFileAtURL:(NSURL *)fileURL fromConnections:(NSArray *)connections;

并停止录制:

-(void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error;

我的问题是如何暂停录制?调查AVFoundation我可以找到一个暂停方法:

-(void)captureOutput:(AVCaptureFileOutput *)captureOutput didPauseRecordingToOutputFileAtURL:(NSURL *)fileURL fromConnections:(NSArray *)connections

但我找不到让它发挥作用的方法。 我搜索了很多,但似乎没有解决我的问题,所以请帮助。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

更改该方法怎么样? 来自AVCam 到 CameraEngine

    #import "CameraEngine.h"


- (void) startPreview
{
    AVCaptureVideoPreviewLayer* preview = [[CameraEngine engine] getPreviewLayer];
    [preview removeFromSuperlayer];
    preview.frame = self.cameraView.bounds;
    [[preview connection] setVideoOrientation:UIInterfaceOrientationLandscapeRight];

    [self.cameraView.layer addSublayer:preview];
}



    - (IBAction)startRecording:(id)sender
    {
        [[CameraEngine engine] startCapture];
    }

    - (IBAction)pauseRecording:(id)sender
    {
        [[CameraEngine engine] pauseCapture];
    }

    - (IBAction)stopRecording:(id)sender
    {
        [[CameraEngine engine] stopCapture];
    }
    - (IBAction)resumeRecording:(id)sender
    {
        [[CameraEngine engine] resumeCapture];
    }