From 98994d0b6529e665863bc9f6125eb3e116e0f9d5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 28 Mar 2021 11:27:37 -0400 Subject: Add playAudioFromSource hotkey (#1570) --- ext/js/display/display.js | 5 +++++ ext/js/pages/settings/keyboard-shortcuts-controller.js | 1 + 2 files changed, 6 insertions(+) (limited to 'ext/js') diff --git a/ext/js/display/display.js b/ext/js/display/display.js index b0805aca..3ae55da0 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -126,6 +126,7 @@ class Display extends EventDispatcher { ['addNoteTermKana', () => { this._tryAddAnkiNoteForSelectedDefinition('term-kana'); }], ['viewNote', () => { this._tryViewAnkiNoteForSelectedDefinition(); }], ['playAudio', () => { this._playAudioCurrent(); }], + ['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)], ['copyHostSelection', () => this._copyHostSelection()], ['nextEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(1, true); }], ['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }] @@ -1830,6 +1831,10 @@ class Display extends EventDispatcher { this._focusEntry(this._index + count * sign, true); } + _onHotkeyActionPlayAudioFromSource(source) { + this._displayAudio.playAudio(this._index, 0, [source]); + } + _closeAllPopupMenus() { for (const popupMenu of PopupMenu.openMenus) { popupMenu.close(); diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js index a63430ee..7dbf5aa2 100644 --- a/ext/js/pages/settings/keyboard-shortcuts-controller.js +++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js @@ -48,6 +48,7 @@ class KeyboardShortcutController { ['addNoteTermKana', {scopes: new Set(['popup', 'search'])}], ['viewNote', {scopes: new Set(['popup', 'search'])}], ['playAudio', {scopes: new Set(['popup', 'search'])}], + ['playAudioFromSource', {scopes: new Set(['popup', 'search']), argument: {template: 'hotkey-argument-audio-source', default: 'jpod101'}}], ['copyHostSelection', {scopes: new Set(['popup'])}], ['scanSelectedText', {scopes: new Set(['web'])}] ]); -- cgit v1.2.3