diff --git a/CHDataManagement/Generator/Blocks/VideoBlock.swift b/CHDataManagement/Generator/Blocks/VideoBlock.swift index 4f7301b..28ba569 100644 --- a/CHDataManagement/Generator/Blocks/VideoBlock.swift +++ b/CHDataManagement/Generator/Blocks/VideoBlock.swift @@ -258,7 +258,7 @@ extension VideoBlock.Option { Note: The `preload` attribute is ignored if `autoplay` is present. */ - enum Preload: String { + enum Preload: String, CaseIterable { /// The author thinks that the browser should load the entire video when the page loads case auto diff --git a/CHDataManagement/Views/Pages/Commands/Insert+Video.swift b/CHDataManagement/Views/Pages/Commands/Insert+Video.swift index 65f60cd..1cd333b 100644 --- a/CHDataManagement/Views/Pages/Commands/Insert+Video.swift +++ b/CHDataManagement/Views/Pages/Commands/Insert+Video.swift @@ -35,6 +35,9 @@ struct InsertableVideo: View, InsertableCommandView { @Published var preload = false + @Published + var preloadType: VideoBlock.Option.Preload = .metadata + var isReady: Bool { videoH265 != nil || videoH264 != nil } @@ -63,7 +66,9 @@ struct InsertableVideo: View, InsertableCommandView { if loop { lines.append(VideoBlock.Key.loop.rawValue) } if muted { lines.append(VideoBlock.Key.muted.rawValue) } if playsinline { lines.append(VideoBlock.Key.playsinline.rawValue) } - if preload { lines.append(VideoBlock.Key.preload.rawValue) } + if preload { + lines.append("\(VideoBlock.Key.preload.rawValue):\(preloadType.rawValue)") + } lines.append("```") return lines.joined(separator: "\n") @@ -104,11 +109,20 @@ struct InsertableVideo: View, InsertableCommandView { Toggle("controls", isOn: $model.controls) Toggle("autoplay", isOn: $model.autoplay) Toggle("loop", isOn: $model.loop) - } - HStack { Toggle("muted", isOn: $model.muted) Toggle("playsinline", isOn: $model.playsinline) + Spacer() + } + HStack { Toggle("preload", isOn: $model.preload) + Picker("", selection: $model.preloadType) { + ForEach(VideoBlock.Option.Preload.allCases, id: \.rawValue) { type in + Text("\(type.rawValue)").tag(type) + } + } + .disabled(!model.preload) + .frame(maxWidth: 100) + Spacer() } } .toggleStyle(.checkbox)