Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/DualCameraKit/DualCameraError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public enum DualCameraError: Error, Equatable {
case .notImplemented:
return "This feature is not yet implemented."
case .permissionDenied:
return "Camera permission was denied by the user."
return "Camera permission was denied – if you want to record please try again and accept the ReplayKit permission prompt."
case .recordingFailed(let reason):
switch reason {
case .assetWriterConfigurationFailed:
Expand Down
2 changes: 2 additions & 0 deletions Sources/DualCameraKit/Screen/DualCameraViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public final class DualCameraViewModel {
viewState = .capturing

do {
// allow for ui updates based on viewState changing
// (e.g., hiding buttons for screenshot-based approach)
try await Task.sleep(for: .seconds(0.25))
let image = try await controller.captureCurrentScreen()
viewState = .ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,23 @@ public actor DualCameraReplayKitVideoRecorder: DualCameraVideoRecording {

let outputURL = configure(outputURL: config.outputURL)

recorder.startRecording()
state = .active(outputURL: outputURL)
DualCameraLogger.session.debug("📹 Screen recording started with ReplayKit")
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
recorder.startRecording { error in
if let error = error {

if let nsError = error as? NSError, nsError.domain == RPRecordingErrorDomain {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test this out on device more. it seems to be flaky whether the DualCameraError.permissionDenied localize desc shows

continuation.resume(throwing: DualCameraError.permissionDenied)
} else {
continuation.resume(throwing: error)
}
return
}

self.state = .active(outputURL: outputURL)
DualCameraLogger.session.debug("📱Screen recording started with ReplayKit")
continuation.resume()
}
}
}

/// Stops an ongoing video recording and returns the URL of the recorded file
Expand Down
Loading