From 50f5b7fcf705957e650cc263f9c6266c56862f49 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 4 Jun 2022 20:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=AD=E9=9F=B3=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E4=B8=8D=E9=87=8A=E6=94=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/components/AudioManager.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/resources/assets/js/components/AudioManager.vue b/resources/assets/js/components/AudioManager.vue index 213b6fe12..61e23eb16 100644 --- a/resources/assets/js/components/AudioManager.vue +++ b/resources/assets/js/components/AudioManager.vue @@ -27,6 +27,7 @@ export default { return { audioSubscribe: null, audioPlay: false, + audioTimer: null, audioId: 0, audioSrc: null, callback: null, @@ -46,6 +47,16 @@ export default { if (typeof this.callback === "function") { this.callback(play) } + // + this.audioTimer && clearTimeout(this.audioTimer); + if (!play) { + this.audioTimer = setTimeout(_ => { + if (!play) { + this.$refs.audio.src = null + this.audioSrc = null + } + }, 3000) + } } }, methods: { @@ -61,9 +72,6 @@ export default { if (typeof msg === "boolean") { if (msg && !ended) { audio.pause() - audio.src = null - this.audioSrc = null - this.audioPlay = false; } return } @@ -74,9 +82,6 @@ export default { audio.play() } else { audio.pause(); - audio.src = null - this.audioSrc = null - this.audioPlay = false; } } else { this.audioId = id;