diff --git a/package.json b/package.json index 0c9ca54ec..4f283d0ac 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "react-i18next": "^15.1.3", "react-is": "18.3.1", "spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6", - "stremio-translations": "github:Stremio/stremio-translations#7c0c337f32163aa13158bb90cd6133da43feafef", + "stremio-translations": "github:Stremio/stremio-translations#1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe", "url": "0.11.4", "use-long-press": "^3.2.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 435a809e8..a55a4f3bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,8 +90,8 @@ importers: specifier: github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6 version: https://codeload.github.com/Stremio/spatial-navigation/tar.gz/64871b1422466f5f45d24ebc8bbd315b2ebab6a6 stremio-translations: - specifier: github:Stremio/stremio-translations#7c0c337f32163aa13158bb90cd6133da43feafef - version: https://codeload.github.com/Stremio/stremio-translations/tar.gz/7c0c337f32163aa13158bb90cd6133da43feafef + specifier: github:Stremio/stremio-translations#1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe + version: https://codeload.github.com/Stremio/stremio-translations/tar.gz/1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe url: specifier: 0.11.4 version: 0.11.4 @@ -4133,8 +4133,8 @@ packages: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} - stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/7c0c337f32163aa13158bb90cd6133da43feafef: - resolution: {tarball: https://codeload.github.com/Stremio/stremio-translations/tar.gz/7c0c337f32163aa13158bb90cd6133da43feafef} + stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe: + resolution: {tarball: https://codeload.github.com/Stremio/stremio-translations/tar.gz/1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe} version: 1.45.0 string-length@4.0.2: @@ -9378,7 +9378,7 @@ snapshots: es-errors: 1.3.0 internal-slot: 1.1.0 - stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/7c0c337f32163aa13158bb90cd6133da43feafef: {} + stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/1bfcb6d2a4f37bb647959ba0bbbd1ade1415c2fe: {} string-length@4.0.2: dependencies: diff --git a/src/common/Shortcuts/shortcuts.json b/src/common/Shortcuts/shortcuts.json index a3ac0f8fe..31333d72f 100644 --- a/src/common/Shortcuts/shortcuts.json +++ b/src/common/Shortcuts/shortcuts.json @@ -74,6 +74,11 @@ "label": "SETTINGS_SHORTCUT_SUBTITLES_DELAY", "combos": [["G"], ["H"]] }, + { + "name": "toggleSubtitles", + "label": "SETTINGS_SHORTCUT_TOGGLE_SUBTITLES", + "combos": [["C"]] + }, { "name": "subtitlesMenu", "label": "SETTINGS_SHORTCUT_MENU_SUBTITLES", diff --git a/src/routes/Player/Player.js b/src/routes/Player/Player.js index 196bb813b..54ad14bc8 100644 --- a/src/routes/Player/Player.js +++ b/src/routes/Player/Player.js @@ -90,6 +90,7 @@ const Player = ({ urlParams, queryParams }) => { const nextVideoPopupDismissed = React.useRef(false); const defaultSubtitlesSelected = React.useRef(false); + const subtitlesEnabled = React.useRef(true); const defaultAudioTrackSelected = React.useRef(false); const [error, setError] = React.useState(null); @@ -670,6 +671,19 @@ const Player = ({ urlParams, queryParams }) => { combo === 1 ? onUpdateSubtitlesSize(-1) : onUpdateSubtitlesSize(1); }, [onUpdateSubtitlesSize, onUpdateSubtitlesSize]); + onShortcut('toggleSubtitles', () => { + const savedTrack = player.streamState?.subtitleTrack; + + if (subtitlesEnabled.current) { + video.setSubtitlesTrack(null); + video.setExtraSubtitlesTrack(null); + } else if (savedTrack?.id) { + savedTrack.embedded ? video.setSubtitlesTrack(savedTrack.id) : video.setExtraSubtitlesTrack(savedTrack.id); + } + + subtitlesEnabled.current = !subtitlesEnabled.current; + }, [player.streamState]); + onShortcut('subtitlesMenu', () => { closeMenus(); if (video.state?.subtitlesTracks?.length > 0 || video.state?.extraSubtitlesTracks?.length > 0) {