mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
let the user select caption size
This commit is contained in:
parent
4fa5a15ad4
commit
96df7fdec5
@ -68,6 +68,7 @@ final class MPVClient: ObservableObject {
|
|||||||
checkError(mpv_set_option_string(mpv, "vo", "libmpv"))
|
checkError(mpv_set_option_string(mpv, "vo", "libmpv"))
|
||||||
checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1"))
|
checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1"))
|
||||||
checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no"))
|
checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "sub-scale", "\(Defaults[.captionsFontScaleSize])"))
|
||||||
|
|
||||||
checkError(mpv_initialize(mpv))
|
checkError(mpv_initialize(mpv))
|
||||||
|
|
||||||
@ -413,6 +414,10 @@ final class MPVClient: ObservableObject {
|
|||||||
setString("sub", "no")
|
setString("sub", "no")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setSubFontSize() {
|
||||||
|
setString("sub-scale", "\(Defaults[.captionsFontScaleSize])")
|
||||||
|
}
|
||||||
|
|
||||||
var tracksCount: Int {
|
var tracksCount: Int {
|
||||||
Int(getString("track-list/count") ?? "-1") ?? -1
|
Int(getString("track-list/count") ?? "-1") ?? -1
|
||||||
}
|
}
|
||||||
|
@ -305,6 +305,7 @@ extension Defaults.Keys {
|
|||||||
static let captionsLanguageCode = Key<String?>("captionsLanguageCode")
|
static let captionsLanguageCode = Key<String?>("captionsLanguageCode")
|
||||||
static let captionsDefaultLanguageCode = Key<String>("captionsDefaultLanguageCode", default: LanguageCodes.English.rawValue)
|
static let captionsDefaultLanguageCode = Key<String>("captionsDefaultLanguageCode", default: LanguageCodes.English.rawValue)
|
||||||
static let captionsFallbackLanguageCode = Key<String>("captionsDefaultFallbackCode", default: LanguageCodes.English.rawValue)
|
static let captionsFallbackLanguageCode = Key<String>("captionsDefaultFallbackCode", default: LanguageCodes.English.rawValue)
|
||||||
|
static let captionsFontScaleSize = Key<Float>("captionsFontScale", default: 1.0)
|
||||||
|
|
||||||
static let lastUsedPlaylistID = Key<Playlist.ID?>("lastPlaylistID")
|
static let lastUsedPlaylistID = Key<Playlist.ID?>("lastPlaylistID")
|
||||||
static let lastAccountIsPublic = Key<Bool>("lastAccountIsPublic", default: false)
|
static let lastAccountIsPublic = Key<Bool>("lastAccountIsPublic", default: false)
|
||||||
|
@ -41,6 +41,7 @@ struct PlayerSettings: View {
|
|||||||
@Default(.captionsAutoShow) private var captionsAutoShow
|
@Default(.captionsAutoShow) private var captionsAutoShow
|
||||||
@Default(.captionsDefaultLanguageCode) private var captionsDefaultLanguageCode
|
@Default(.captionsDefaultLanguageCode) private var captionsDefaultLanguageCode
|
||||||
@Default(.captionsFallbackLanguageCode) private var captionsFallbackLanguageCode
|
@Default(.captionsFallbackLanguageCode) private var captionsFallbackLanguageCode
|
||||||
|
@Default(.captionsFontScaleSize) private var captionsFontScaleSize
|
||||||
|
|
||||||
@ObservedObject private var accounts = AccountsModel.shared
|
@ObservedObject private var accounts = AccountsModel.shared
|
||||||
|
|
||||||
@ -106,7 +107,12 @@ struct PlayerSettings: View {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Section(header: SettingsHeader(text: "Captions".localized())) {
|
Section(header: SettingsHeader(text: "Captions".localized())) {
|
||||||
|
#if os(tvOS)
|
||||||
|
Text("Size").font(.subheadline)
|
||||||
|
#endif
|
||||||
|
captionsFontScaleSizePicker
|
||||||
showCaptionsAutoShowToggle
|
showCaptionsAutoShowToggle
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
captionDefaultLanguagePicker
|
captionDefaultLanguagePicker
|
||||||
captionFallbackLanguagePicker
|
captionFallbackLanguagePicker
|
||||||
@ -331,6 +337,20 @@ struct PlayerSettings: View {
|
|||||||
Toggle("Always show captions", isOn: $captionsAutoShow)
|
Toggle("Always show captions", isOn: $captionsAutoShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var captionsFontScaleSizePicker: some View {
|
||||||
|
Picker("Size", selection: $captionsFontScaleSize) {
|
||||||
|
Text("Small").tag(Float(0.5))
|
||||||
|
Text("Medium").tag(Float(1.0))
|
||||||
|
Text("Large").tag(Float(2.0))
|
||||||
|
}
|
||||||
|
.onChange(of: captionsFontScaleSize) { _ in
|
||||||
|
PlayerModel.shared.mpvBackend.client.setSubFontSize()
|
||||||
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
.labelsHidden()
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
private var captionDefaultLanguagePicker: some View {
|
private var captionDefaultLanguagePicker: some View {
|
||||||
Picker("Default language", selection: $captionsDefaultLanguageCode) {
|
Picker("Default language", selection: $captionsDefaultLanguageCode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user