[FREQ] Support for volume buttons to take a photo using AVCaptureEventInteraction
Apple added support for camera use of the volume buttons to trigger taking a photo using AVCaptureEventInteraction.
See https://developer.apple.com/documentation/avkit/avcaptureeventinteraction
Thanks!
Is this in ios 18?
From: Steve Splonskowski @.> Sent: Sunday, September 22, 2024 4:17 PM To: Mijick/CameraView @.> Cc: Subscribed @.***> Subject: [Mijick/CameraView] Please add support for volume buttons to take a photo using AVCaptureEventInteraction (Issue #47)
Apple added support for camera use of the volume buttons to trigger taking a photo using AVCaptureEventInteraction.
See https://developer.apple.com/documentation/avkit/avcaptureeventinteraction
Thanks!
— Reply to this email directly, view it on GitHubhttps://github.com/Mijick/CameraView/issues/47, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFWGZYK43S6YAGEJOF533NLZX4QWJAVCNFSM6AAAAABOU3IFOKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2DCMRUGE2TKOI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hey @splons,
I hope to address this next week, as I am still working on patch 3.0.0 for PopupView.
Have a nice day, Tomasz
Thank you. This new API became available in iOS 17.2
Turns out there is a SwiftUI modifier called .onCameraCaptureEvent that can easily be added to capture the physical volume button presses and then trigger photo capture. I added this to my custom camera screen implementation.
So maybe this feature request is not necessary -- particularly if you are using SwiftUI.
.onCameraCaptureEvent { event in
if event.phase == .ended {
captureOutput()
}
}
Here is an example of how to integrate the .onCameraCaptureEvent modifier into your MCamera set
struct CustomCameraScreen: MCameraScreen {
@ObservedObject var cameraManager: CameraManager
let namespace: Namespace.ID
let closeMCameraAction: () -> ()
var body: some View {
if #available(iOS 18.0, *) {
DefaultCameraScreen(
cameraManager: cameraManager,
namespace: namespace,
closeMCameraAction: closeMCameraAction
)
// add camera screen modifiers here
.onCameraCaptureEvent { event in
if event.phase == .ended {
captureOutput()
}
}
} else {
DefaultCameraScreen(
cameraManager: cameraManager,
namespace: namespace,
closeMCameraAction: closeMCameraAction
)
// add camera screen modifiers here
}
}
}
Using AVCaptureEventInteraction would still be helpful as it would allow MijickCamera to be used in Control Center, Action button, or Lock screen extensions as outlined in Creating a camera experience for the Lock Screen