diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-06-13 23:16:17 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-06-14 20:44:38 -0700 |
commit | 15f2744f04ae59ba78700f65a8512aacde859f82 (patch) | |
tree | 3499f5018e29508c8d790425db3dbff9bbe16a07 /ext/fg/js | |
parent | e0f91b9a8a0f2e7db0362ff10623f94c6673d926 (diff) |
Audio
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/client.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js index 4ac40b65..5b8cfe29 100644 --- a/ext/fg/js/client.js +++ b/ext/fg/js/client.js @@ -20,6 +20,7 @@ class Client { constructor() { this.popup = new Popup(); + this.audio = null; this.lastMousePos = null; this.lastRange = null; this.activateKey = 16; @@ -170,8 +171,13 @@ class Client { api_pronounce(index) { const dfn = this.definitions[index]; const url = `http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=${dfn.reading}&kanji=${dfn.expression}`; - const audio = new Audio(url); - audio.play(); + + if (this.audio !== null) { + this.audio.pause(); + } + + this.audio = new Audio(url); + this.audio.play(); } api_displayKanji(kanji) { |