From fdaeb3a43329af6656c74f41a18c0d86eaf70f39 Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 20 Jul 2023 19:01:37 +0200 Subject: [PATCH] recit player fadeout bug fix 2 #2240 --- src/components/RecitPlayer.vue | 82 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/src/components/RecitPlayer.vue b/src/components/RecitPlayer.vue index d14517e..c379113 100644 --- a/src/components/RecitPlayer.vue +++ b/src/components/RecitPlayer.vue @@ -48,48 +48,52 @@ export default { if(o){ - this.fadeOutInterval = setInterval(()=>{ - if (this.recit_plyr_player.volume > 0.05) { - // console.log(`recitPlayer fading volume:${this.recit_plyr_player.volume}`); - this.recit_plyr_player.volume *= 0.9; - }else{ - this.recit_plyr_player.volume = 0.6; - this.recit_plyr_player.stop(); - clearInterval(this.fadeOutInterval); - - // if during the the fadeout we opened an other recit, play it - if (this.opened_recit) { - this.recit_plyr_player.source = { - type: 'audio', - sources: [ - { - src: this.opened_recit.file.url, - type: this.opened_recit.file.filemine, - } - ] - } - this.recit_plyr_player.volume = 0.6; - this.recit_plyr_player.play(); - } - } - }, 1); - } - if (n && !this.fadeOutInterval) { // if new and we are not in in a fadeout - if(n.file.url){ - // console.log(`switching source`); - this.recit_plyr_player.source = { - type: 'audio', - sources: [ - { - src: n.file.url, - type: n.file.filemine, - } - ] - } + this.fadeOutInterval = setInterval(()=>{ + if (this.recit_plyr_player.volume > 0.05) { + // console.log(`recitPlayer fading volume:${this.recit_plyr_player.volume}`); + this.recit_plyr_player.volume *= 0.9; + }else{ + console.log('fadeout done'); this.recit_plyr_player.volume = 0.6; - this.recit_plyr_player.play(); + this.recit_plyr_player.stop(); + clearInterval(this.fadeOutInterval); + this.fadeOutInterval = null; + + // if during the the fadeout we opened an other recit, play it + if (this.opened_recit) { + console.log('recitPlayer fade done, this.opened_recit', this.opened_recit); + this.recit_plyr_player.source = { + type: 'audio', + sources: [ + { + src: this.opened_recit.file.url, + type: this.opened_recit.file.filemine, + } + ] + } + this.recit_plyr_player.volume = 0.6; + this.recit_plyr_player.play(); + } } + }, 1); + } + console.log('recitPlayer new n', n, this.fadeOutInterval); + if (n && !this.fadeOutInterval) { // if new and we are not in in a fadeout + if(n.file.url){ + // console.log(`switching source`); + this.recit_plyr_player.source = { + type: 'audio', + sources: [ + { + src: n.file.url, + type: n.file.filemine, + } + ] + } + this.recit_plyr_player.volume = 0.6; + this.recit_plyr_player.play(); } + } } },