diff options
Diffstat (limited to 'ext/mixed/js')
-rw-r--r-- | ext/mixed/js/api.js | 8 | ||||
-rw-r--r-- | ext/mixed/js/audio-system.js | 10 | ||||
-rw-r--r-- | ext/mixed/js/display.js | 8 |
3 files changed, 15 insertions, 11 deletions
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 2192fa98..7dc77fb6 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -93,8 +93,8 @@ const api = (() => { return this._invoke('templateRender', {data, template, marker}); } - audioGetUri(definition, source, details) { - return this._invoke('audioGetUri', {definition, source, details}); + audioGetUri(source, expression, reading, details) { + return this._invoke('audioGetUri', {source, expression, reading, details}); } commandExec(command, params) { @@ -197,6 +197,10 @@ const api = (() => { return this._invoke('isTabSearchPopup', {tabId}); } + getDefinitionAudio(sources, expression, reading, details) { + return this._invoke('getDefinitionAudio', {sources, expression, reading, details}); + } + // Invoke functions with progress deleteDictionary(dictionaryName, onProgress) { diff --git a/ext/mixed/js/audio-system.js b/ext/mixed/js/audio-system.js index 9bf12510..4a49c135 100644 --- a/ext/mixed/js/audio-system.js +++ b/ext/mixed/js/audio-system.js @@ -78,8 +78,8 @@ class AudioSystem { } } - async getDefinitionAudio(definition, sources, details) { - const key = `${definition.expression}:${definition.reading}`; + async getDefinitionAudio(sources, expression, reading, details) { + const key = `${expression}:${reading}`; const hasCache = (this._cache !== null && !details.disableCache); if (hasCache) { @@ -95,7 +95,7 @@ class AudioSystem { for (let i = 0, ii = sources.length; i < ii; ++i) { const source = sources[i]; - const uri = await this._getAudioUri(definition, source, details); + const uri = await this._getAudioUri(source, expression, reading, details); if (uri === null) { continue; } try { @@ -129,10 +129,10 @@ class AudioSystem { // NOP } - _getAudioUri(definition, source, details) { + _getAudioUri(source, expression, reading, details) { return ( this._audioUriBuilder !== null ? - this._audioUriBuilder.getUri(definition, source, details) : + this._audioUriBuilder.getUri(source, expression, reading, details) : null ); } diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index ea6b52c0..6fdab46b 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -42,8 +42,8 @@ class Display extends EventDispatcher { this._audioFallback = null; this._audioSystem = new AudioSystem({ audioUriBuilder: { - getUri: async (definition, source, details) => { - return await api.audioGetUri(definition, source, details); + getUri: async (source, expression, reading, details) => { + return await api.audioGetUri(source, expression, reading, details); } }, useCache: true @@ -1071,7 +1071,7 @@ class Display extends EventDispatcher { try { this.setSpinnerVisible(true); - const expression = expressionIndex === -1 ? definition : definition.expressions[expressionIndex]; + const {expression, reading} = expressionIndex === -1 ? definition : definition.expressions[expressionIndex]; this._stopPlayingAudio(); @@ -1079,7 +1079,7 @@ class Display extends EventDispatcher { try { const {sources, textToSpeechVoice, customSourceUrl} = this._options.audio; let index; - ({audio, index} = await this._audioSystem.getDefinitionAudio(expression, sources, {textToSpeechVoice, customSourceUrl})); + ({audio, index} = await this._audioSystem.getDefinitionAudio(sources, expression, reading, {textToSpeechVoice, customSourceUrl})); info = `From source ${1 + index}: ${sources[index]}`; } catch (e) { if (this._audioFallback === null) { |