Reputation: 31
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
Upvotes: 3
Views: 2721
Reputation: 1
session.setAllowHapticsAndSystemSoundsDuringRecording(true) is good for me!!
I'm using AudioQueueServices + CHHapticEngine
Upvotes: 0
Reputation: 61
You can use setAllowHapticsAndSystemSoundsDuringRecording
from iOS13 and later.
try session.setAllowHapticsAndSystemSoundsDuringRecording(true)
Upvotes: 6
Reputation: 27363
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.
Upvotes: 1