Merge pull request #679 from stonerl/mpv-settings

Advanced Settings: cache-pause-initial
This commit is contained in:
Arkadiusz Fal 2024-05-19 09:51:26 +02:00 committed by GitHub
commit 81be57904b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 60 additions and 12 deletions

View File

@ -60,7 +60,7 @@ final class MPVClient: ObservableObject {
checkError(mpv_set_option_string(mpv, "input-media-keys", "yes")) checkError(mpv_set_option_string(mpv, "input-media-keys", "yes"))
#endif #endif
checkError(mpv_set_option_string(mpv, "cache-pause-initial", "yes")) checkError(mpv_set_option_string(mpv, "cache-pause-initial", Defaults[.mpvCachePauseInital] ? "yes" : "no"))
checkError(mpv_set_option_string(mpv, "cache-secs", Defaults[.mpvCacheSecs])) checkError(mpv_set_option_string(mpv, "cache-secs", Defaults[.mpvCacheSecs]))
checkError(mpv_set_option_string(mpv, "cache-pause-wait", Defaults[.mpvCachePauseWait])) checkError(mpv_set_option_string(mpv, "cache-pause-wait", Defaults[.mpvCachePauseWait]))
checkError(mpv_set_option_string(mpv, "keep-open", "yes")) checkError(mpv_set_option_string(mpv, "keep-open", "yes"))

View File

@ -266,6 +266,7 @@ extension Defaults.Keys {
static let mpvEnableLogging = Key<Bool>("mpvEnableLogging", default: false) static let mpvEnableLogging = Key<Bool>("mpvEnableLogging", default: false)
static let mpvCacheSecs = Key<String>("mpvCacheSecs", default: "120") static let mpvCacheSecs = Key<String>("mpvCacheSecs", default: "120")
static let mpvCachePauseWait = Key<String>("mpvCachePauseWait", default: "3") static let mpvCachePauseWait = Key<String>("mpvCachePauseWait", default: "3")
static let mpvCachePauseInital = Key<Bool>("cache-pause-initial", default: true)
static let mpvDeinterlace = Key<Bool>("mpvDeinterlace", default: false) static let mpvDeinterlace = Key<Bool>("mpvDeinterlace", default: false)
static let showCacheStatus = Key<Bool>("showCacheStatus", default: false) static let showCacheStatus = Key<Bool>("showCacheStatus", default: false)

View File

@ -5,6 +5,7 @@ struct AdvancedSettings: View {
@Default(.showMPVPlaybackStats) private var showMPVPlaybackStats @Default(.showMPVPlaybackStats) private var showMPVPlaybackStats
@Default(.mpvCacheSecs) private var mpvCacheSecs @Default(.mpvCacheSecs) private var mpvCacheSecs
@Default(.mpvCachePauseWait) private var mpvCachePauseWait @Default(.mpvCachePauseWait) private var mpvCachePauseWait
@Default(.mpvCachePauseInital) private var mpvCachePauseInital
@Default(.mpvDeinterlace) private var mpvDeinterlace @Default(.mpvDeinterlace) private var mpvDeinterlace
@Default(.mpvEnableLogging) private var mpvEnableLogging @Default(.mpvEnableLogging) private var mpvEnableLogging
@Default(.showCacheStatus) private var showCacheStatus @Default(.showCacheStatus) private var showCacheStatus
@ -68,9 +69,32 @@ struct AdvancedSettings: View {
mpvEnableLoggingToggle mpvEnableLoggingToggle
#endif #endif
Toggle(isOn: $mpvCachePauseInital) {
HStack {
Text("cache-pause-initial")
#if !os(tvOS)
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-pause-initial")!) {
Image(systemName: "link")
.font(.footnote)
}
#if os(macOS)
.onHover(perform: onHover(_:))
#endif
#endif
}
}
HStack { HStack {
Text("cache-secs") Text("cache-secs")
.frame(minWidth: 140, alignment: .leading) #if !os(tvOS)
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-secs")!) {
Image(systemName: "link")
.font(.footnote)
#if os(macOS)
.onHover(perform: onHover(_:))
#endif
}
#endif
TextField("cache-secs", text: $mpvCacheSecs) TextField("cache-secs", text: $mpvCacheSecs)
#if !os(macOS) #if !os(macOS)
.keyboardType(.numberPad) .keyboardType(.numberPad)
@ -79,8 +103,19 @@ struct AdvancedSettings: View {
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
HStack { HStack {
Group {
Text("cache-pause-wait") Text("cache-pause-wait")
.frame(minWidth: 140, alignment: .leading) #if !os(tvOS)
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-pause-wait")!) {
Image(systemName: "link")
}
.font(.footnote)
#endif
#if os(macOS)
.onHover(perform: onHover(_:))
#endif
}.frame(minWidth: 140, alignment: .leading)
TextField("cache-pause-wait", text: $mpvCachePauseWait) TextField("cache-pause-wait", text: $mpvCachePauseWait)
#if !os(macOS) #if !os(macOS)
.keyboardType(.numberPad) .keyboardType(.numberPad)
@ -88,7 +123,20 @@ struct AdvancedSettings: View {
} }
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
Toggle("deinterlace", isOn: $mpvDeinterlace) Toggle(isOn: $mpvDeinterlace) {
HStack {
Text("deinterlace")
#if !os(tvOS)
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-deinterlace")!) {
Image(systemName: "link")
.font(.footnote)
}
#if os(macOS)
.onHover(perform: onHover(_:))
#endif
#endif
}
}
if mpvEnableLogging { if mpvEnableLogging {
logButton logButton
@ -103,20 +151,19 @@ struct AdvancedSettings: View {
} }
@ViewBuilder var mpvFooter: some View { @ViewBuilder var mpvFooter: some View {
let url = "https://mpv.io/manual/master" let url = "https://mpv.io/manual/stable/"
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text("Restart the app to apply the settings above.") Text("Restart the app to apply the settings above.")
.padding(.bottom, 1)
VStack(alignment: .leading, spacing: 2) { VStack(alignment: .leading, spacing: 2) {
#if os(tvOS) #if os(tvOS)
Text("More info can be found in MPV Documentation:") Text("More info can be found in MPV reference manual:")
Text(url) Text(url)
#else #else
Text("More info can be found in:") Text("Further information can be found in the ")
Link("MPV Documentation", destination: URL(string: url)!) + Text("MPV reference manual").underline().bold()
#if os(macOS) + Text(" by clicking on the link icon next to the option.")
.onHover(perform: onHover(_:))
#endif
#endif #endif
} }
} }