aboutsummaryrefslogtreecommitdiff
path: root/ext/js/media/audio-system.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-05-30 12:15:07 -0400
committerGitHub <noreply@github.com>2021-05-30 12:15:07 -0400
commitefd35de67f6700ecf4f49a87d310d99cefbaa328 (patch)
treeb031d5c24b3e118efb868bf1b098bb10cf3b2c3e /ext/js/media/audio-system.js
parent0f0e80aadb97c95d307dcd97edabd2087d0a1743 (diff)
Refactor display audio options (#1717)
* Update how options are updated and stored in DisplayAudio * Add source list * Improve menus for custom json * Clear cache after options update * Move function * Update public API * Simplify playing audio from a specific source * Simplify audio list * Refactor audio source usage * Refactoring * Refactor argument names * Fix incorrect source usage * Remove unused * Remove return value * Simplify details * Simplify Anki card audio details * Update the data that is passed to AudioDownloader * Simplify schema handling * Remove unnecessary details
Diffstat (limited to 'ext/js/media/audio-system.js')
-rw-r--r--ext/js/media/audio-system.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/js/media/audio-system.js b/ext/js/media/audio-system.js
index cc2bcfc0..03e68767 100644
--- a/ext/js/media/audio-system.js
+++ b/ext/js/media/audio-system.js
@@ -42,11 +42,11 @@ class AudioSystem extends EventDispatcher {
return this._fallbackAudio;
}
- createAudio(url, source) {
+ createAudio(url, sourceType) {
return new Promise((resolve, reject) => {
const audio = new Audio(url);
audio.addEventListener('loadeddata', () => {
- if (!this._isAudioValid(audio, source)) {
+ if (!this._isAudioValid(audio, sourceType)) {
reject(new Error('Could not retrieve audio'));
} else {
resolve(audio);
@@ -70,8 +70,8 @@ class AudioSystem extends EventDispatcher {
this.trigger('voiceschanged', e);
}
- _isAudioValid(audio, source) {
- switch (source) {
+ _isAudioValid(audio, sourceType) {
+ switch (sourceType) {
case 'jpod101':
{
const duration = audio.duration;