【问题标题】:AVCaptureSession pause?AVCaptureSession 暂停?
【发布时间】:2010-09-02 07:28:50
【问题描述】:
【问题讨论】:
标签:
ios4
avfoundation
avcapturesession
【解决方案1】:
您可以禁用输入连接,而不是暂停会话。
例如
<your_video_preview_layer>.connection.enabled = NO;
这样它就不会消耗来自输入设备的数据。
希望这就是你要找的。p>
【解决方案2】:
没有办法“暂停”会话,但您可以随时启动捕获会话并让它继续运行。如果您正在捕获静止图像,只需在准备好时调用 captureStillImageAsynchronouslyFromConnection。如果你正在捕捉视频,你可以让你的 captureOutput:didOutputSampleBuffer:fromConnection: 方法在委托中丢弃帧,直到你想对它们做些什么。您甚至可以在没有输出设备的情况下开始捕获会话,直到您准备好(尚未尝试过)。
【解决方案3】:
这是我为防止 UI 在调用 -startRunning 时锁定最初的 1-2 秒所做的。
1) Add UIActivityIndicator
2) Add observer to AVCaptureSession
3) call -startRunning in a background thread
4) Resume the UI in the notification callback