From 15b93060c76ee4d59eb8ef90f6e1f8dea4c34ac9 Mon Sep 17 00:00:00 2001 From: guidocella Date: Sat, 16 Dec 2017 19:56:53 +0100 Subject: Add option to play audio automatically --- ext/mixed/js/display.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ext/mixed/js') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 5d3c4f2e..43eb93c1 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -185,8 +185,7 @@ class Display { 80: /* p */ () => { if (e.altKey) { if ($('.entry').eq(this.index).data('type') === 'term') { - const expressionIndex = this.options.general.resultOutputMode === 'merge' ? 0 : -1; - this.audioPlay(this.definitions[this.index], expressionIndex); + this.audioPlay(this.definitions[this.index], this.firstExpressionIndex); } return true; @@ -258,6 +257,10 @@ class Display { this.container.html(content); this.entryScrollIntoView(context && context.index || 0); + if (this.options.general.autoPlayAudio && this.options.general.audioSource !== 'disabled') { + this.autoPlayAudio(); + } + $('.action-add-note').click(this.onNoteAdd.bind(this)); $('.action-view-note').click(this.onNoteView.bind(this)); $('.action-play-audio').click(this.onAudioPlay.bind(this)); @@ -309,6 +312,10 @@ class Display { } } + autoPlayAudio() { + this.audioPlay(this.definitions[0], this.firstExpressionIndex); + } + async adderButtonUpdate(modes, sequence) { try { const states = await apiDefinitionsAddable(this.definitions, modes); @@ -422,6 +429,10 @@ class Display { } } + get firstExpressionIndex() { + return this.options.general.resultOutputMode === 'merge' ? 0 : -1; + } + static clozeBuild(sentence, source) { const result = { sentence: sentence.text.trim() -- cgit v1.2.3