2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
2021-10-23 11:51:02 +00:00
|
|
|
struct PlaybackSettings: View {
|
2021-11-03 23:40:01 +00:00
|
|
|
@Default(.instances) private var instances
|
|
|
|
@Default(.playerInstanceID) private var playerInstanceID
|
2021-09-25 08:18:22 +00:00
|
|
|
@Default(.quality) private var quality
|
2021-11-03 23:00:17 +00:00
|
|
|
@Default(.playerSidebar) private var playerSidebar
|
2021-11-03 23:14:09 +00:00
|
|
|
@Default(.showKeywords) private var showKeywords
|
2021-11-03 23:00:17 +00:00
|
|
|
|
|
|
|
#if os(iOS)
|
|
|
|
private var idiom: UIUserInterfaceIdiom {
|
|
|
|
UIDevice.current.userInterfaceIdiom
|
|
|
|
}
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2021-11-03 23:40:01 +00:00
|
|
|
playerInstanceSection
|
|
|
|
|
2021-11-03 23:14:09 +00:00
|
|
|
qualitySection
|
|
|
|
|
|
|
|
#if !os(tvOS)
|
|
|
|
playerSection
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
Spacer()
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-11-03 23:40:01 +00:00
|
|
|
private var playerInstanceSection: some View {
|
|
|
|
Section(header: Text("Preferred playback source")) {
|
|
|
|
Picker("Source", selection: $playerInstanceID) {
|
|
|
|
Text("Best available stream").tag(String?.none)
|
|
|
|
|
|
|
|
ForEach(instances) { instance in
|
|
|
|
Text(instance.longDescription).tag(Optional(instance.id))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.labelsHidden()
|
|
|
|
#if os(iOS)
|
|
|
|
.pickerStyle(.automatic)
|
|
|
|
#elseif os(tvOS)
|
|
|
|
.pickerStyle(.inline)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 23:14:09 +00:00
|
|
|
private var qualitySection: some View {
|
2021-09-25 08:18:22 +00:00
|
|
|
Section(header: Text("Quality")) {
|
|
|
|
Picker("Quality", selection: $quality) {
|
|
|
|
ForEach(Stream.ResolutionSetting.allCases, id: \.self) { resolution in
|
|
|
|
Text(resolution.description).tag(resolution)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.labelsHidden()
|
|
|
|
|
|
|
|
#if os(iOS)
|
|
|
|
.pickerStyle(.automatic)
|
2021-09-28 18:06:05 +00:00
|
|
|
#elseif os(tvOS)
|
|
|
|
.pickerStyle(.inline)
|
2021-09-25 08:18:22 +00:00
|
|
|
#endif
|
2021-11-03 23:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 23:14:09 +00:00
|
|
|
private var playerSection: some View {
|
|
|
|
Section(header: Text("Player")) {
|
|
|
|
#if os(iOS)
|
|
|
|
if idiom == .pad {
|
|
|
|
sidebarPicker
|
|
|
|
}
|
|
|
|
#elseif os(macOS)
|
|
|
|
sidebarPicker
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-11-03 23:14:09 +00:00
|
|
|
Toggle("Show video keywords", isOn: $showKeywords)
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 23:00:17 +00:00
|
|
|
|
2021-11-03 23:14:09 +00:00
|
|
|
private var sidebarPicker: some View {
|
|
|
|
Picker("Sidebar", selection: $playerSidebar) {
|
|
|
|
#if os(macOS)
|
|
|
|
Text("Show sidebar").tag(PlayerSidebarSetting.always)
|
|
|
|
#endif
|
2021-11-03 23:00:17 +00:00
|
|
|
|
|
|
|
#if os(iOS)
|
2021-11-03 23:14:09 +00:00
|
|
|
Text("Show sidebar when space permits").tag(PlayerSidebarSetting.whenFits)
|
2021-09-25 08:18:22 +00:00
|
|
|
#endif
|
2021-11-03 23:14:09 +00:00
|
|
|
|
|
|
|
Text("Hide sidebar").tag(PlayerSidebarSetting.never)
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
2021-11-03 23:14:09 +00:00
|
|
|
.labelsHidden()
|
|
|
|
|
|
|
|
#if os(iOS)
|
|
|
|
.pickerStyle(.automatic)
|
|
|
|
#elseif os(tvOS)
|
|
|
|
.pickerStyle(.inline)
|
|
|
|
#endif
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
}
|