CameraView icon indicating copy to clipboard operation
CameraView copied to clipboard

[FREQ] Support for volume buttons to take a photo using AVCaptureEventInteraction

Open splons opened this issue 1 year ago • 6 comments

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!

splons avatar Sep 22 '24 20:09 splons

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: @.***>

ghost avatar Sep 23 '24 03:09 ghost

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

FulcrumOne avatar Sep 23 '24 09:09 FulcrumOne

Thank you. This new API became available in iOS 17.2

splons avatar Sep 23 '24 13:09 splons

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()
	}
}

splons avatar Jun 18 '25 17:06 splons

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
        }
    }
}

splons avatar Jun 26 '25 21:06 splons

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

im-jersh avatar Jul 30 '25 05:07 im-jersh