Skip to content

Always display Find Online Subtitle OSD messages #4992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2024
Merged

Conversation

low-batt
Copy link
Contributor

This commit will:

  • Add an isAlwaysShown property to OSDMessage that is true for OSD messages emitted by the Find Online Subtitles feature
  • Change PlayerCore.sendOSD to send messages whose isAlwaysShown property is true even when the enableOSD setting is false
  • Change MainWindowController.displayOSD to display messages whose isAlwaysShown property is true even when the IINA OSD is disabled due to the user enabling mpv's OSD

These changes correct a problem where IINA's Find Online Subtitles feature appears to do nothing when the OSD is disabled. This feature uses the OSD to interact with the user. Failing to display the messages breaks the feature.


Description:

This commit will:
- Add an isAlwaysShown property to OSDMessage that is true for OSD
  messages emitted by the Find Online Subtitles feature
- Change PlayerCore.sendOSD to send messages whose isAlwaysShown
  property is true even when the enableOSD setting is false
- Change MainWindowController.displayOSD to display messages whose
  isAlwaysShown property is true even when the IINA OSD is disabled due
  to the user enabling mpv's OSD

These changes correct a problem where IINA's Find Online Subtitles
feature appears to do nothing when the OSD is disabled. This feature
uses the OSD to interact with the user. Failing to display the messages
breaks the feature.
@low-batt
Copy link
Contributor Author

This does not address customWithDetail which is used by plugins. I'm guessing there may be a similar problem with messages emitted by plugins.

Thoughts?

@lhc70000
Copy link
Member

isAlwaysShown looks confusing to me. Initially I thought it would make the OSD persistently displayed on the screen and not hiding anymore. Maybe it can be something more straightforward, like alwaysEnabled or ignoreDisableOSD?

This commit will:
- Add an alwaysEnabled property to OSDMessage that is true for OSD
  messages emitted by the Find Online Subtitles feature
- Change PlayerCore.sendOSD to send messages whose alwaysEnabled
  property is true even when the enableOSD setting is false
- Change MainWindowController.displayOSD to display messages whose
  alwaysEnabled property is true even when the IINA OSD is disabled
  due to the user enabling mpv's OSD

These changes correct a problem where IINA's Find Online Subtitles
feature appears to do nothing when the OSD is disabled. This feature
uses the OSD to interact with the user. Failing to display the messages
breaks the feature.
@low-batt
Copy link
Contributor Author

Makes sense. I was too close to the code to notice that it could be interpreted that way. I renamed it to alwaysEnabled.

We still need to figure out how to properly solve the similar issue for plugins.

@@ -2158,7 +2158,7 @@ class PlayerCore: NSObject {

func sendOSD(_ osd: OSDMessage, autoHide: Bool = true, forcedTimeout: Float? = nil, accessoryView: NSView? = nil, context: Any? = nil, external: Bool = false) {
// querying `mainWindow.isWindowLoaded` will initialize mainWindow unexpectly
guard mainWindow.loaded && Preference.bool(for: .enableOSD) else { return }
guard mainWindow.loaded, Preference.bool(for: .enableOSD) || osd.alwaysEnabled else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using , here instead of &&?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find what Swift considers the best practice in this case and only found people debating that. The advice in the Medium post Chaining logical expressions with commas in Swift about expressions using commas being easier to read than complex expressions reflects what I was thinking. Using && would require adding () around the || expression. I was also thinking that the comma was more like swift has you have to use it when using let.

I'm good with whatever style the group wants to use. Let me know if you want me to switch this to &&.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just asking and also found it a little bit confusing. I think it's alright to use , here to avoid the parentheses.

@lhc70000 lhc70000 merged commit 5e9c00e into develop Jun 18, 2024
@uiryuu uiryuu deleted the always-osd branch June 18, 2024 23:53
@low-batt low-batt linked an issue Jul 4, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

External Subtitles > Search Online... doesn't do anything
2 participants