gpt4 book ai didi

ios - 断断续续的快门声

转载 作者:可可西里 更新时间:2023-11-01 00:58:14 25 4
gpt4 key购买 nike

我正在使用以下代码在我的 iOS 应用程序中拍照:

self.stillImageOutput.captureStillImageAsynchronously(from: videoConnection) {
// Do some stuff here
self.captureSession.stopRunning()
// Do some more stuff
}

出于某种原因,在捕获 block 中调用 stopRunning() 会使快门声音断断续续。如果我将其移除,则快门声音非常好。我怎样才能防止这种情况发生?

最佳答案

您不想异步访问 UI。根据您的描述,听起来异步 block 可能是口吃的来源。为了让主队列播放您的声音,您可以尝试两种方法:

// everything is going swimmingly until you play the sound...
// grab the main queue
DispatchQueue.main.async {
// play your sound
}
// and live happily ever after

另一种方法:

// everything is going swimmingly until you play the sound...
// grab the main queue
DispatchQueue.main.suspend()
// play your sound
DispatchQueue.main.resume()
// and live happily ever after

关于ios - 断断续续的快门声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40086943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com