Improve video command
This commit is contained in:
@ -258,7 +258,7 @@ extension VideoBlock.Option {
|
|||||||
|
|
||||||
Note: The `preload` attribute is ignored if `autoplay` is present.
|
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
|
/// The author thinks that the browser should load the entire video when the page loads
|
||||||
case auto
|
case auto
|
||||||
|
@ -35,6 +35,9 @@ struct InsertableVideo: View, InsertableCommandView {
|
|||||||
@Published
|
@Published
|
||||||
var preload = false
|
var preload = false
|
||||||
|
|
||||||
|
@Published
|
||||||
|
var preloadType: VideoBlock.Option.Preload = .metadata
|
||||||
|
|
||||||
var isReady: Bool {
|
var isReady: Bool {
|
||||||
videoH265 != nil || videoH264 != nil
|
videoH265 != nil || videoH264 != nil
|
||||||
}
|
}
|
||||||
@ -63,7 +66,9 @@ struct InsertableVideo: View, InsertableCommandView {
|
|||||||
if loop { lines.append(VideoBlock.Key.loop.rawValue) }
|
if loop { lines.append(VideoBlock.Key.loop.rawValue) }
|
||||||
if muted { lines.append(VideoBlock.Key.muted.rawValue) }
|
if muted { lines.append(VideoBlock.Key.muted.rawValue) }
|
||||||
if playsinline { lines.append(VideoBlock.Key.playsinline.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("```")
|
lines.append("```")
|
||||||
return lines.joined(separator: "\n")
|
return lines.joined(separator: "\n")
|
||||||
@ -104,11 +109,20 @@ struct InsertableVideo: View, InsertableCommandView {
|
|||||||
Toggle("controls", isOn: $model.controls)
|
Toggle("controls", isOn: $model.controls)
|
||||||
Toggle("autoplay", isOn: $model.autoplay)
|
Toggle("autoplay", isOn: $model.autoplay)
|
||||||
Toggle("loop", isOn: $model.loop)
|
Toggle("loop", isOn: $model.loop)
|
||||||
}
|
|
||||||
HStack {
|
|
||||||
Toggle("muted", isOn: $model.muted)
|
Toggle("muted", isOn: $model.muted)
|
||||||
Toggle("playsinline", isOn: $model.playsinline)
|
Toggle("playsinline", isOn: $model.playsinline)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
HStack {
|
||||||
Toggle("preload", isOn: $model.preload)
|
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)
|
.toggleStyle(.checkbox)
|
||||||
|
Reference in New Issue
Block a user