diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-15 20:47:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-15 20:47:35 -0500 |
commit | f2a387237bac02d93d1664ed7acb6a10108915b6 (patch) | |
tree | 17db44dea4a4d14ceafd73e608fd53367b0189fe /ext/js/media | |
parent | 7027d537a914cbd5a2f8aa6accf221efeed4af0d (diff) |
Update audio downloading to support specifying an exact array index (#1405)
Diffstat (limited to 'ext/js/media')
-rw-r--r-- | ext/js/media/audio-downloader.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index 4e77419b..bb8d40a8 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -49,9 +49,12 @@ class AudioDownloader { return []; } - async downloadExpressionAudio(sources, expression, reading, details) { + async downloadExpressionAudio(sources, preferredAudioIndex, expression, reading, details) { for (const source of sources) { - const infoList = await this.getExpressionAudioInfoList(source, expression, reading, details); + let infoList = await this.getExpressionAudioInfoList(source, expression, reading, details); + if (typeof preferredAudioIndex === 'number') { + infoList = (preferredAudioIndex >= 0 && preferredAudioIndex < infoList.length ? [infoList[preferredAudioIndex]] : []); + } for (const info of infoList) { switch (info.type) { case 'url': |