Ayman Abdallah
Ayman Abdallah

Reputation: 31

How can I play a haptic feedback while AvCapture Session is running?

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

Answers (3)

iRonCheng
iRonCheng

Reputation: 1

session.setAllowHapticsAndSystemSoundsDuringRecording(true) is good for me!!
I'm using AudioQueueServices + CHHapticEngine

Upvotes: 0

Shibo Qin
Shibo Qin

Reputation: 61

You can use setAllowHapticsAndSystemSoundsDuringRecording from iOS13 and later.

try session.setAllowHapticsAndSystemSoundsDuringRecording(true)

Upvotes: 6

samwize
samwize

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

Related Questions