SwiftUI Photo and Video recording view.
To avoid unexpected crashes be sure to enable the camera and audio access in your info.plist
Tap to take an image and hold the button to start recording view. You can see a flip camera icon on the top left corner that will toggle front-back cameras. All parameters are customizable, so feel free to get your preferred view.
https://github.com/karenxpn/CameraXPN
import SwiftUI
import CameraXPN
struct ContentView: View {
var body: some View {
CameraXPN(action: { url, data in
print(url)
print(data.count)
}, font: .subheadline, permissionMessgae: "Permission Denied")
}
}
action
: action that returns url of our content with extension video.mov or photo.jpg and binary datafont
: font you need to present user media buttonpermissionMessgae
: a message that will be shown if video or audio access is deniedretakeButtonBackground
: retakeButton background descriptionretakeButtonForeground
: retake button image colorbackButtonBackground
: backButton background colorbackButtonForeground
: backButton button image colorcloseButtonBackground
: close button background colorcloseButtonForeground
: close button image colortakeImageButtonColor
: take image button colorrecordVideoButtonColor
: record video button colorflipCameraBackground
: flip camera button backgroundflipCameraForeground
: flip camera button image coloruseMediaContent
: use media text that can be replaceduseMediaButtonForeground
: use media button text coloruseMediaButtonBackground
: use media button background colorvideoAllowed
: video can be allowed or notmaxVideoDuration
: set maximum duration of the video you want to record