Skip to content

Commit

Permalink
Close support subtitle visibility, iina#4235
Browse files Browse the repository at this point in the history
This commit will:
- Add a Hide Subtitles/Show Subtitles item to the Subtitles menu
- Add a Hide Second Subtitles/Show Second Subtitles item to the
  Subtitles menu
- Add a key binding mapping v to cycle sub-visibility
- Add a key binding mapping Alt-v to cycle secondary-sub-visibility
- Add a new OSD messages Subtitles Hidden/Visible
- Add a new OSD messages Second Subtitles Hidden/Visible
- Add secondary-sub-visibility to watch-later-options
- Add logging of watch-later-options

These changes add a graphical user interface for the mpv features that
control subtitle visibility.
  • Loading branch information
low-batt authored and svobs committed Mar 13, 2023
1 parent ffa591c commit 18c4b6c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
6 changes: 4 additions & 2 deletions iina/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@
"osd.sub_delay.later" = "Subtitle Delay: %.2fs Later";
"osd.sub_delay.earlier" = "Subtitle Delay: %.2fs Earlier";
"osd.subtitle_pos" = "Subtitle Position: %.1f";
"osd.sub_visibility" = "Subtitle Visibility: %@";
"osd.sub_second_visibility" = "Second Subtitle Visibility: %@";
"osd.sub_hidden" = "Subtitles Hidden";
"osd.sub_visible" = "Subtitles Visible";
"osd.sub_second_hidden" = "Second Subtitles Hidden";
"osd.sub_second_visible" = "Second Subtitles Visible";
"osd.mute" = "Mute";
"osd.unmute" = "Unmute";
"osd.screenshot" = "Screenshot Captured";
Expand Down
4 changes: 2 additions & 2 deletions iina/MPVController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1240,15 +1240,15 @@ class MPVController: NSObject {
if let visible = UnsafePointer<Bool>(OpaquePointer(property.data))?.pointee {
if player.info.isSubVisible != visible {
player.info.isSubVisible = visible
player.sendOSD(.subVisible(visible))
player.sendOSD(visible ? .subVisible : .subHidden)
}
}

case MPVOption.Subtitles.secondarySubVisibility:
if let visible = UnsafePointer<Bool>(OpaquePointer(property.data))?.pointee {
if player.info.isSecondSubVisible != visible {
player.info.isSecondSubVisible = visible
player.sendOSD(.secondSubVisible(visible))
player.sendOSD(visible ? .secondSubVisible : .secondSubHidden)
}
}

Expand Down
26 changes: 14 additions & 12 deletions iina/OSDMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ enum OSDMessage {
case audioDelay(Double)
case subDelay(Double)
case subScale(Double)
case subVisible(Bool)
case secondSubVisible(Bool)
case subHidden
case subVisible
case secondSubHidden
case secondSubVisible
case subPos(Double)
case mute
case unMute
Expand Down Expand Up @@ -174,17 +176,17 @@ enum OSDMessage {
.withProgress(value / 100)
)

case .subVisible(let enabled):
return (
String(format: NSLocalizedString("osd.sub_visibility", comment: "Subtitle Visibility: %@"), enabled ? NSLocalizedString("general.on", comment: "On") : NSLocalizedString("general.off", comment: "Off")),
.normal
)
case .subHidden:
return (NSLocalizedString("osd.sub_hidden", comment: "Subtitles Hidden"), .normal)

case .secondSubVisible(let enabled):
return (
String(format: NSLocalizedString("osd.sub_second_visibility", comment: "Second Subtitle Visibility: %@"), enabled ? NSLocalizedString("general.on", comment: "On") : NSLocalizedString("general.off", comment: "Off")),
.normal
)
case .subVisible:
return (NSLocalizedString("osd.sub_visible", comment: "Subtitles Visible"), .normal)

case .secondSubHidden:
return (NSLocalizedString("osd.sub_second_hidden", comment: "Second Subtitles Hidden"), .normal)

case .secondSubVisible:
return (NSLocalizedString("osd.sub_second_visible", comment: "Second Subtitles Visible"), .normal)

case .mute:
return (NSLocalizedString("osd.mute", comment: "Mute"), .normal)
Expand Down
6 changes: 4 additions & 2 deletions iina/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@
"osd.sub_delay.later" = "Subtitle Delay: %.2fs Later";
"osd.sub_delay.earlier" = "Subtitle Delay: %.2fs Earlier";
"osd.subtitle_pos" = "Subtitle Position: %.1f";
"osd.sub_visibility" = "Subtitle Visibility: %@";
"osd.sub_second_visibility" = "Second Subtitle Visibility: %@";
"osd.sub_hidden" = "Subtitles Hidden";
"osd.sub_visible" = "Subtitles Visible";
"osd.sub_second_hidden" = "Second Subtitles Hidden";
"osd.sub_second_visible" = "Second Subtitles Visible";"osd.mute" = "Mute";
"osd.mute" = "Mute";
"osd.unmute" = "Unmute";
"osd.screenshot" = "Screenshot Captured";
Expand Down

0 comments on commit 18c4b6c

Please sign in to comment.