From 39322472e4e8b84287ee23d802ef4dae87d4def9 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 1 Mar 2022 18:26:20 +0800 Subject: [PATCH] implement increase/descrease volume hotkeys #254 --- public/configStore.js | 3 +++ src/App.jsx | 4 +++- src/components/KeyboardShortcuts.jsx | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/configStore.js b/public/configStore.js index 5c3325f6..e2ec7384 100644 --- a/public/configStore.js +++ b/public/configStore.js @@ -66,6 +66,9 @@ const defaultKeyBindings = [ { keys: 'h', action: 'toggleHelp' }, { keys: 'shift+/', action: 'toggleKeyboardShortcuts' }, { keys: 'escape', action: 'closeActiveScreen' }, + + { keys: 'alt+up', action: 'increaseVolume' }, + { keys: 'alt+down', action: 'decreaseVolume' }, ]; const defaults = { diff --git a/src/App.jsx b/src/App.jsx index 65072158..c1dc10da 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1816,6 +1816,8 @@ const App = memo(() => { enableOnlyCurrentSegment, toggleCurrentSegmentEnabled, fixInvalidDuration: tryFixInvalidDuration, + increaseVolume: () => setPlaybackVolume((val) => Math.min(1, val + 0.07)), + decreaseVolume: () => setPlaybackVolume((val) => Math.max(0, val - 0.07)), }; function tryMainActions() { @@ -1857,7 +1859,7 @@ const App = memo(() => { if (match) return bubble; return true; // bubble the event - }, [addCutSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, currentSegIndexSafe, cutSegmentsHistory, disableAllSegments, enableAllSegments, enableOnlyCurrentSegment, exportConfirmVisible, extractAllStreams, goToTimecode, increaseRotation, invertAllCutSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegmentPress, pause, play, removeCutSegment, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, setCutEnd, setCutStart, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentEnabled, toggleHelp, toggleKeyboardShortcuts, toggleKeyframeCut, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, tryFixInvalidDuration, userHtml5ifyCurrentFile, zoomRel]); + }, [addCutSegment, askSetStartTimeOffset, batchFileJump, batchOpenSelectedFile, captureSnapshot, changePlaybackRate, cleanupFilesDialog, clearSegments, closeBatch, closeExportConfirm, concatCurrentBatch, concatDialogVisible, convertFormatBatch, createFixedDurationSegments, createNumSegments, currentSegIndexSafe, cutSegmentsHistory, disableAllSegments, enableAllSegments, enableOnlyCurrentSegment, exportConfirmVisible, extractAllStreams, goToTimecode, increaseRotation, invertAllCutSegments, jumpCutEnd, jumpCutStart, jumpSeg, jumpTimelineEnd, jumpTimelineStart, keyboardNormalSeekSpeed, keyboardSeekAccFactor, keyboardShortcutsVisible, onExportConfirm, onExportPress, onLabelSegmentPress, pause, play, removeCutSegment, reorderSegsByStartTime, seekClosestKeyframe, seekRel, seekRelPercent, setCutEnd, setCutStart, setPlaybackVolume, shortStep, shuffleSegments, splitCurrentSegment, timelineToggleComfortZoom, toggleCaptureFormat, toggleCurrentSegmentEnabled, toggleHelp, toggleKeyboardShortcuts, toggleKeyframeCut, togglePlay, toggleSegmentsList, toggleStreamsSelector, toggleStripAudio, tryFixInvalidDuration, userHtml5ifyCurrentFile, zoomRel]); useKeyboard({ keyBindings, onKeyPress }); diff --git a/src/components/KeyboardShortcuts.jsx b/src/components/KeyboardShortcuts.jsx index 0c95dc5f..29e459a5 100644 --- a/src/components/KeyboardShortcuts.jsx +++ b/src/components/KeyboardShortcuts.jsx @@ -180,6 +180,14 @@ const KeyboardShortcuts = memo(({ name: t('Slow down playback more'), category: playbackCategory, }, + increaseVolume: { + name: t('Increase audio volume'), + category: playbackCategory, + }, + decreaseVolume: { + name: t('Decrease audio volume'), + category: playbackCategory, + }, // seekingCategory seekPreviousFrame: {