refactor: merge player volume and playback speed shortcuts

This commit is contained in:
Tim 2026-05-08 14:41:40 +02:00
parent 24cc613dc7
commit 20954f405d
4 changed files with 18 additions and 38 deletions

View file

@ -41,7 +41,7 @@
"react-i18next": "^15.7.4", "react-i18next": "^15.7.4",
"react-is": "18.3.1", "react-is": "18.3.1",
"spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6", "spatial-navigation-polyfill": "github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "github:Stremio/stremio-translations#d9cd2fb88268b365b14101452665de698f9c15e9", "stremio-translations": "github:Stremio/stremio-translations#c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0",
"url": "0.11.4", "url": "0.11.4",
"use-long-press": "^3.3.0" "use-long-press": "^3.3.0"
}, },

View file

@ -90,8 +90,8 @@ importers:
specifier: github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6 specifier: github:Stremio/spatial-navigation#64871b1422466f5f45d24ebc8bbd315b2ebab6a6
version: https://codeload.github.com/Stremio/spatial-navigation/tar.gz/64871b1422466f5f45d24ebc8bbd315b2ebab6a6 version: https://codeload.github.com/Stremio/spatial-navigation/tar.gz/64871b1422466f5f45d24ebc8bbd315b2ebab6a6
stremio-translations: stremio-translations:
specifier: github:Stremio/stremio-translations#d9cd2fb88268b365b14101452665de698f9c15e9 specifier: github:Stremio/stremio-translations#c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0
version: https://codeload.github.com/Stremio/stremio-translations/tar.gz/d9cd2fb88268b365b14101452665de698f9c15e9 version: https://codeload.github.com/Stremio/stremio-translations/tar.gz/c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0
url: url:
specifier: 0.11.4 specifier: 0.11.4
version: 0.11.4 version: 0.11.4
@ -4421,8 +4421,8 @@ packages:
resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/d9cd2fb88268b365b14101452665de698f9c15e9: stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0:
resolution: {tarball: https://codeload.github.com/Stremio/stremio-translations/tar.gz/d9cd2fb88268b365b14101452665de698f9c15e9} resolution: {tarball: https://codeload.github.com/Stremio/stremio-translations/tar.gz/c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0}
version: 1.52.0 version: 1.52.0
string-length@4.0.2: string-length@4.0.2:
@ -10000,7 +10000,7 @@ snapshots:
es-errors: 1.3.0 es-errors: 1.3.0
internal-slot: 1.1.0 internal-slot: 1.1.0
stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/d9cd2fb88268b365b14101452665de698f9c15e9: {} stremio-translations@https://codeload.github.com/Stremio/stremio-translations/tar.gz/c2d68dc590ac7d56f0df5e69a2144ba83e0d5ef0: {}
string-length@4.0.2: string-length@4.0.2:
dependencies: dependencies:

View file

@ -50,14 +50,9 @@
"combos": [["ArrowLeft"], ["Shift", "ArrowLeft"]] "combos": [["ArrowLeft"], ["Shift", "ArrowLeft"]]
}, },
{ {
"name": "volumeUp", "name": "volume",
"label": "SETTINGS_SHORTCUT_VOLUME_UP", "label": "SETTINGS_SHORTCUT_VOLUME",
"combos": [["ArrowUp"]] "combos": [["ArrowUp"], ["ArrowDown"]]
},
{
"name": "volumeDown",
"label": "SETTINGS_SHORTCUT_VOLUME_DOWN",
"combos": [["ArrowDown"]]
}, },
{ {
"name": "mute", "name": "mute",
@ -75,14 +70,9 @@
"combos": [["G"], ["H"]] "combos": [["G"], ["H"]]
}, },
{ {
"name": "speedDown", "name": "speed",
"label": "SETTINGS_SHORTCUT_DECREASE_PLAYBACK_SPEED", "label": "SETTINGS_SHORTCUT_PLAYBACK_SPEED",
"combos": [["["]] "combos": [["["], ["]"]]
},
{
"name": "speedUp",
"label": "SETTINGS_SHORTCUT_INCREASE_PLAYBACK_SPEED",
"combos": [["]"]]
}, },
{ {
"name": "toggleSubtitles", "name": "toggleSubtitles",

View file

@ -584,15 +584,10 @@ const Player = ({ urlParams, queryParams }) => {
video.state.muted === true ? onUnmuteRequested() : onMuteRequested(); video.state.muted === true ? onUnmuteRequested() : onMuteRequested();
}, [video.state.muted], !menusOpen); }, [video.state.muted], !menusOpen);
onShortcut('volumeUp', () => { onShortcut('volume', (combo) => {
if (video.state.volume !== null) { if (video.state.volume !== null) {
onVolumeChangeRequested(Math.min(video.state.volume + 5, 200)); const volume = combo === 0 ? Math.min(video.state.volume + 5, 200) : Math.max(video.state.volume - 5, 0);
} onVolumeChangeRequested(volume);
}, [video.state.volume], !menusOpen);
onShortcut('volumeDown', () => {
if (video.state.volume !== null) {
onVolumeChangeRequested(Math.max(video.state.volume - 5, 0));
} }
}, [video.state.volume], !menusOpen); }, [video.state.volume], !menusOpen);
@ -617,15 +612,10 @@ const Player = ({ urlParams, queryParams }) => {
} }
}, [video.state.playbackSpeed, toggleSpeedMenu]); }, [video.state.playbackSpeed, toggleSpeedMenu]);
onShortcut('speedUp', () => { onShortcut('speed', (combo) => {
if (video.state.playbackSpeed !== null) { if (video.state.playbackSpeed !== null) {
onPlaybackSpeedChanged(Math.min(video.state.playbackSpeed + 0.25, 2)); const speed = combo === 0 ? Math.max(video.state.playbackSpeed - 0.25, 0.25) : Math.min(video.state.playbackSpeed + 0.25, 2);
} onPlaybackSpeedChanged(speed);
}, [video.state.playbackSpeed, onPlaybackSpeedChanged], !menusOpen);
onShortcut('speedDown', () => {
if (video.state.playbackSpeed !== null) {
onPlaybackSpeedChanged(Math.max(video.state.playbackSpeed - 0.25, 0.25));
} }
}, [video.state.playbackSpeed, onPlaybackSpeedChanged], !menusOpen); }, [video.state.playbackSpeed, onPlaybackSpeedChanged], !menusOpen);