From 15f2744f04ae59ba78700f65a8512aacde859f82 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 13 Jun 2016 23:16:17 -0700 Subject: [PATCH] Audio --- ext/fg/js/client.js | 10 ++++++++-- 1 file 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) {