swift 如何在AvCapture会话运行时播放触觉反馈?

esbemjvw  于 2023-08-02  发布在  Swift
关注(0)|答案(3)|浏览(143)

当我的Avcapture会话正在运行并准备录制视频时,我无法播放音频文件、振动或播放任何触觉反馈?我只找到了目标c的解决方案,但找不到斯威夫特。
目标C溶液:Using vibrate and AVCaptureSession at the same time

kuhbmx9i

kuhbmx9i1#

您可以使用iOS13及更高版本中的setAllowHapticsAndSystemSoundsDuringRecording

try session.setAllowHapticsAndSystemSoundsDuringRecording(true)

字符串

xytpbqjk

xytpbqjk2#

只要您在AVCaptureSession中使用麦克风,触觉反馈就不会播放。
苹果试图防止振动干扰麦克风捕获。这在https://developer.apple.com/documentation/audiotoolbox/1405202-audioservicesplayalertsound中有说明
如果您还没有从麦克风录音(正如您所说,您只是处于“就绪状态”),那么解决方案是延迟添加麦克风,直到您想开始录音。
当然,在录制时,您可能仍然不播放任何触觉反馈。

disho6za

disho6za3#

session.setAllowHapticsAndSystemSoundsDuringRecording(true)对我来说很好!!
我正在使用AudioQueueServices + CHHapticEngine

相关问题