Skip to content

feat: add subtitle toggle hotkey#961

Open
schembriaiden wants to merge 3 commits intoDonutWare:developfrom
schembriaiden:feat/subtitle-shortcut
Open

feat: add subtitle toggle hotkey#961
schembriaiden wants to merge 3 commits intoDonutWare:developfrom
schembriaiden:feat/subtitle-shortcut

Conversation

@schembriaiden
Copy link
Copy Markdown
Contributor

@schembriaiden schembriaiden commented Apr 17, 2026

Pull Request Description

This pull request introduces a new "toggle subtitles" hotkey feature to the video player, allowing users to quickly enable or disable subtitles using a keyboard shortcut. The implementation includes localization, hotkey mapping, and logic for toggling subtitles, including handling multiple subtitle tracks and remembering the user's last selection.

New Subtitle Toggle Feature:

  • Added a new toggleSubtitles hotkey to the VideoHotKeys enum, mapped by default to the "T" key (LogicalKeyboardKey.keyT).
  • Implemented the _toggleSubtitles method in _DesktopControlsState to handle toggling subtitles on/off, supporting both single and multiple subtitle tracks and remembering the last selected subtitle.
  • Integrated the new hotkey into the video player controls so pressing the hotkey triggers subtitle toggling.

Localization:

  • Added the toggleSubtitles string to the English localization file (app_en.arb) for display in the UI and settings.
  • Updated the VideoHotKeys label mapping to include the new toggleSubtitles key for proper display in settings menus.

Codebase Maintenance:

  • Added the necessary import for media_streams_model.dart to support subtitle toggling logic.
  • Introduced a _lastSelectedSubtitleIndex state variable to remember the user's last subtitle choice across toggles.

Logic is as follow:

Press toggle:

  1. If there is only 1 type of subtitle it just uses it
  2. If there is multiple subtitle types:
    1. First time it asks you to select the one you want
    2. After it keeps using the same one.

Issue Being Fixed

Resolves #957

Screenshots / Recordings

Tested On

  • Android
  • Android TV
  • iOS
  • Linux
  • Windows
  • macOS
  • Web

Checklist

  • If a new package was added, did you ensure it works for all supported platforms? Is the package well maintained
  • Check that any changes are related to the issue at hand.

_vDragLastValue = null;
}

void _toggleSubtitles() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely sure about the logic here. Does it make sense for the user to press the "toggle" button to all of a sudden ask what subtitles they want to toggle in-between?

Would it make more sense to just do nothing if the subtitles are already disabled and only allow toggling when a subtitle is enabled?

No strong opinion on my end just thinking out loud.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not against the idea, but I think this might lead users to open issues on GitHub saying that the toggle key is not working, when in fact it would be working. Then from experience I know that most people don't check previous issues before opening one which would lead to a bunch of duplicate issues regarding this.

VideoHotKeys.takeScreenshot => KeyCombination(key: LogicalKeyboardKey.keyG),
VideoHotKeys.takeScreenshotClean =>
KeyCombination(key: LogicalKeyboardKey.keyG, modifier: LogicalKeyboardKey.controlLeft),
VideoHotKeys.toggleSubtitles => KeyCombination(key: LogicalKeyboardKey.keyT),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Silly question but why T? Youtube for instance uses the C button for "Captions"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was initially going to go with C to mirror Youtube's logic, but since the request suggested T I just went with that, we can do whatever I don't mind.

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.

2 participants