#if !os(tvOS)
import SwiftUI
import UniformTypeIdentifiers
/// UTType for a finished capture, derived from its file extension.
/// Live Photo exports the HEVC motion clip (the paired still goes to Photos via Save).
func exportType(for out: CaptureOutput) -> UTType {
switch out {
case .file(let url, _):
switch url.pathExtension.lowercased() {
case "png": return .png
case "heic": return .heic
case "mov": return .quickTimeMovie
case "mp4": return .mpeg4Movie
default: return .data
}
case .livePhoto:
return .quickTimeMovie
}
}
/// Export-only FileDocument that copies an already-rendered capture file to a
/// user-chosen location via `.fileExporter`.
struct ExportedCapture: FileDocument {
static var readableContentTypes: [UTType] { [] }
let url: URL
let type: UTType
init(url: URL, type: UTType) { self.url = url; self.type = type }
init(configuration: ReadConfiguration) throws { throw CocoaError(.fileReadUnsupportedScheme) }
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
try FileWrapper(url: url)
}
}
#endif