问题
When my Avcapture session is running and ready to record a video , I cannot play and audio files, vibrate or play any haptic feedback? I only found a solution for objective c but not swift.
Objective C Solution : Using vibrate and AVCaptureSession at the same time
回答1:
As long as you are using microphone in the AVCaptureSession, the haptic feedback will not play.
Apple tries to prevent the vibration from disrupting the microphone capture. This is noted in https://developer.apple.com/documentation/audiotoolbox/1405202-audioservicesplayalertsound
If you are not recording from the mic yet (as you said you are just in a "ready state"), then a solution is to delay adding the mic until you want to start recording.
Of course, while recording, you still may not play any haptic feedback.
回答2:
You can use setAllowHapticsAndSystemSoundsDuringRecording from iOS13 and later.
try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
来源:https://stackoverflow.com/questions/44582128/how-can-i-play-a-haptic-feedback-while-avcapture-session-is-running