diff options
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r-- | ext/bg/js/backend.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index abf4c673..60a87916 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -34,7 +34,7 @@ class Backend { this.options = null; this.optionsSchema = null; this.defaultAnkiFieldTemplates = null; - this.audioSystem = new AudioSystem(); + this.audioSystem = new AudioSystem({getAudioUri: this._getAudioUri.bind(this)}); this.optionsContext = { depth: 0, url: window.location.href @@ -764,6 +764,16 @@ class Backend { // Utilities + async _getAudioUri(definition, source, details) { + let optionsContext = (typeof details === 'object' && details !== null ? details.optionsContext : null); + if (!(typeof optionsContext === 'object' && optionsContext !== null)) { + optionsContext = this.optionsContext; + } + + const options = this.getOptions(optionsContext); + return await audioGetUrl(definition, source, options); + } + async _injectScreenshot(definition, fields, screenshot) { let usesScreenshot = false; for (const fieldValue of Object.values(fields)) { |