mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +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, "demuxer-lavf-analyzeduration", "1"))
|
||||
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))
|
||||
|
||||
@ -413,6 +414,10 @@ final class MPVClient: ObservableObject {
|
||||
setString("sub", "no")
|
||||
}
|
||||
|
||||
func setSubFontSize() {
|
||||
setString("sub-scale", "\(Defaults[.captionsFontScaleSize])")
|
||||
}
|
||||
|
||||
var tracksCount: Int {
|
||||
Int(getString("track-list/count") ?? "-1") ?? -1
|
||||
}
|
||||
|
@ -305,6 +305,7 @@ extension Defaults.Keys {
|
||||
static let captionsLanguageCode = Key<String?>("captionsLanguageCode")
|
||||
static let captionsDefaultLanguageCode = Key<String>("captionsDefaultLanguageCode", 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 lastAccountIsPublic = Key<Bool>("lastAccountIsPublic", default: false)
|
||||
|
@ -41,6 +41,7 @@ struct PlayerSettings: View {
|
||||
@Default(.captionsAutoShow) private var captionsAutoShow
|
||||
@Default(.captionsDefaultLanguageCode) private var captionsDefaultLanguageCode
|
||||
@Default(.captionsFallbackLanguageCode) private var captionsFallbackLanguageCode
|
||||
@Default(.captionsFontScaleSize) private var captionsFontScaleSize
|
||||
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
|
||||
@ -106,7 +107,12 @@ struct PlayerSettings: View {
|
||||
#endif
|
||||
|
||||
Section(header: SettingsHeader(text: "Captions".localized())) {
|
||||
#if os(tvOS)
|
||||
Text("Size").font(.subheadline)
|
||||
#endif
|
||||
captionsFontScaleSizePicker
|
||||
showCaptionsAutoShowToggle
|
||||
|
||||
#if !os(tvOS)
|
||||
captionDefaultLanguagePicker
|
||||
captionFallbackLanguagePicker
|
||||
@ -331,6 +337,20 @@ struct PlayerSettings: View {
|
||||
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)
|
||||
private var captionDefaultLanguagePicker: some View {
|
||||
Picker("Default language", selection: $captionsDefaultLanguageCode) {
|
||||
|
Loading…
Reference in New Issue
Block a user