summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-10 19:58:06 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-10 21:30:38 -0400
commit1d516b3b24eb6b89aa3a345341b6c1c35e24dfed (patch)
treed32c926ab268f73142f8672ce9b115a5610c04e5 /ext/bg
parent8ae1da427756a9a1e057b3518c4069ac7d5b4b3a (diff)
Implement audio fallbacks
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/background.html1
-rw-r--r--ext/bg/js/audio.js12
-rw-r--r--ext/bg/search.html2
3 files changed, 9 insertions, 6 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 3b37db87..194d4a45 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -27,6 +27,7 @@
<script src="/bg/js/templates.js"></script>
<script src="/bg/js/translator.js"></script>
<script src="/bg/js/util.js"></script>
+ <script src="/mixed/js/audio.js"></script>
<script src="/mixed/js/japanese.js"></script>
<script src="/bg/js/backend.js"></script>
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index 26896027..0bf836df 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -136,6 +136,7 @@ function audioBuildFilename(definition) {
return filename += '.mp3';
}
+ return null;
}
async function audioInject(definition, fields, sources, optionsContext) {
@@ -157,11 +158,12 @@ async function audioInject(definition, fields, sources, optionsContext) {
audioSourceDefinition = definition.expressions[0];
}
- const url = await audioBuildUrl(audioSourceDefinition, sources[0], optionsContext);
- const filename = audioBuildFilename(audioSourceDefinition);
-
- if (url && filename) {
- definition.audio = {url, filename};
+ const {url} = await audioGetFromSources(audioSourceDefinition, sources, optionsContext, false);
+ if (url !== null) {
+ const filename = audioBuildFilename(audioSourceDefinition);
+ if (filename !== null) {
+ definition.audio = {url, filename};
+ }
}
return true;
diff --git a/ext/bg/search.html b/ext/bg/search.html
index e71824d3..3284ed43 100644
--- a/ext/bg/search.html
+++ b/ext/bg/search.html
@@ -36,7 +36,6 @@
<script src="/mixed/js/extension.js"></script>
- <script src="/bg/js/audio.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/bg/js/handlebars.js"></script>
<script src="/bg/js/templates.js"></script>
@@ -44,6 +43,7 @@
<script src="/fg/js/document.js"></script>
<script src="/fg/js/source.js"></script>
<script src="/fg/js/util.js"></script>
+ <script src="/mixed/js/audio.js"></script>
<script src="/mixed/js/display.js"></script>
<script src="/mixed/js/japanese.js"></script>
<script src="/mixed/js/scroll.js"></script>