aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 21:44:51 -0500
committerGitHub <noreply@github.com>2020-03-07 21:44:51 -0500
commitd022d61b1a66614e1837585afcb53a25253b643a (patch)
tree40659359b076fed2ad57980f88e26d2ff95a12c5 /ext/bg/js/audio.js
parentb8eb5e6016834cc751c973239e1e4604fe9799ee (diff)
parentdceaa853098a465b2eaa1b90900b5c1832131f26 (diff)
Merge pull request #399 from toasted-nutbread/audio-system-refactor
Audio system refactor
Diffstat (limited to 'ext/bg/js/audio.js')
-rw-r--r--ext/bg/js/audio.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index 972e2b8b..c94121ae 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/*global jpIsStringEntirelyKana, audioGetFromSources*/
+/*global jpIsStringEntirelyKana*/
const audioUrlBuilders = new Map([
['jpod101', async (definition) => {
@@ -154,7 +154,7 @@ function audioBuildFilename(definition) {
return null;
}
-async function audioInject(definition, fields, sources, optionsContext) {
+async function audioInject(definition, fields, sources, optionsContext, audioSystem) {
let usesAudio = false;
for (const fieldValue of Object.values(fields)) {
if (fieldValue.includes('{audio}')) {
@@ -171,12 +171,10 @@ async function audioInject(definition, fields, sources, optionsContext) {
const expressions = definition.expressions;
const audioSourceDefinition = Array.isArray(expressions) ? expressions[0] : definition;
- const {url} = await audioGetFromSources(audioSourceDefinition, sources, optionsContext, true);
- if (url !== null) {
- const filename = audioBuildFilename(audioSourceDefinition);
- if (filename !== null) {
- definition.audio = {url, filename};
- }
+ const {uri} = await audioSystem.getDefinitionAudio(audioSourceDefinition, sources, {tts: false, optionsContext});
+ const filename = audioBuildFilename(audioSourceDefinition);
+ if (filename !== null) {
+ definition.audio = {url: uri, filename};
}
return true;