mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
Default player instance setting
This commit is contained in:
parent
2fcbe94e6f
commit
505fbdbc51
@ -52,7 +52,7 @@ extension PlayerModel {
|
|||||||
savedTime = currentItem.playbackTime
|
savedTime = currentItem.playbackTime
|
||||||
|
|
||||||
loadAvailableStreams(currentVideo!) { streams in
|
loadAvailableStreams(currentVideo!) { streams in
|
||||||
guard let stream = streams.first else {
|
guard let stream = self.preferredStream(streams) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +65,14 @@ extension PlayerModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func preferredStream(_ streams: [Stream]) -> Stream? {
|
||||||
|
if let id = Defaults[.playerInstanceID] {
|
||||||
|
return streams.first { $0.instance.id == id }
|
||||||
|
} else {
|
||||||
|
return streams.first
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func advanceToNextItem() {
|
func advanceToNextItem() {
|
||||||
addCurrentItemToHistory()
|
addCurrentItemToHistory()
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ extension Defaults.Keys {
|
|||||||
|
|
||||||
static let quality = Key<Stream.ResolutionSetting>("quality", default: .hd720pFirstThenBest)
|
static let quality = Key<Stream.ResolutionSetting>("quality", default: .hd720pFirstThenBest)
|
||||||
static let playerSidebar = Key<PlayerSidebarSetting>("playerSidebar", default: PlayerSidebarSetting.defaultValue)
|
static let playerSidebar = Key<PlayerSidebarSetting>("playerSidebar", default: PlayerSidebarSetting.defaultValue)
|
||||||
|
static let playerInstanceID = Key<Instance.ID?>("playerInstance")
|
||||||
static let showKeywords = Key<Bool>("showKeywords", default: false)
|
static let showKeywords = Key<Bool>("showKeywords", default: false)
|
||||||
|
|
||||||
static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: [])
|
static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: [])
|
||||||
|
@ -2,6 +2,8 @@ import Defaults
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct PlaybackSettings: View {
|
struct PlaybackSettings: View {
|
||||||
|
@Default(.instances) private var instances
|
||||||
|
@Default(.playerInstanceID) private var playerInstanceID
|
||||||
@Default(.quality) private var quality
|
@Default(.quality) private var quality
|
||||||
@Default(.playerSidebar) private var playerSidebar
|
@Default(.playerSidebar) private var playerSidebar
|
||||||
@Default(.showKeywords) private var showKeywords
|
@Default(.showKeywords) private var showKeywords
|
||||||
@ -13,6 +15,8 @@ struct PlaybackSettings: View {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
playerInstanceSection
|
||||||
|
|
||||||
qualitySection
|
qualitySection
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
@ -24,6 +28,24 @@ struct PlaybackSettings: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var qualitySection: some View {
|
private var qualitySection: some View {
|
||||||
Section(header: Text("Quality")) {
|
Section(header: Text("Quality")) {
|
||||||
Picker("Quality", selection: $quality) {
|
Picker("Quality", selection: $quality) {
|
||||||
|
Loading…
Reference in New Issue
Block a user