From 19a0c29015d8c993e708e53f44a9a0f11cbe63d4 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 27 Jan 2025 23:02:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E5=A5=BD=E7=9A=84=E6=9C=AA?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=B8=8D=E6=92=AD=E6=94=BE=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/audio/player.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/module/audio/player.ts b/src/module/audio/player.ts index ed824cc..d65c440 100644 --- a/src/module/audio/player.ts +++ b/src/module/audio/player.ts @@ -35,16 +35,6 @@ export class AudioPlayer extends EventEmitter { this.ac = new AudioContext(); this.gain = this.ac.createGain(); this.gain.connect(this.ac.destination); - - const func = () => { - this.ac.resume(); - document.body.removeEventListener('mousedown', func); - document.body.removeEventListener('touchstart', func); - document.body.removeEventListener('keydown', func); - }; - document.body.addEventListener('mousedown', func, { capture: true }); - document.body.addEventListener('touchstart', func, { capture: true }); - document.body.addEventListener('keydown', func, { capture: true }); } /** @@ -427,9 +417,10 @@ export class AudioRoute * 开始播放这个音频 * @param when 从音频的什么时候开始播放,单位秒 */ - play(when: number = 0) { + async play(when: number = 0) { if (this.status === AudioStatus.Playing) return; this.link(); + await this.player.ac.resume(); if (this.effectRoute.length > 0) { const first = this.effectRoute[0]; this.source.connect(first);