I want to create UX like iOS14 video camera. It have vibration when record button is tapped.
I know the way to vibrate short time using UINotificationFeedbackGenerator()
Swift : Make a very short vibration
But it is not worked if captureSession have audio input.
How can I play a haptic feedback while AvCapture Session is running?
This code is worked but it have blackout phase when it working. So not good enough.
UIImpactFeedbackGenerator Not Working When Audio Device Added to AVCaptureSession
self.session.stopRunning()
// Play haptic
UINotificationFeedbackGenerator().notificationOccurred(.warning)
// Not completely sure if this delay is needed but you might need to wait until the run loop after the haptic plays to resume capture session
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.session.startRunning()
}
It is really helpful if let me know how to work Haptic Feedback on AVcaptureSession.