From 140802a7a0b428565dc4b4670e9e9311e7360510 Mon Sep 17 00:00:00 2001 From: tangbzai <47456577+tangbzai@users.noreply.github.com> Date: Tue, 4 Jul 2023 22:00:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(h5):=20InnerAudioContext=E5=92=8CBackground?= =?UTF-8?q?AudioManager=E5=87=BA=E7=8E=B0=E9=94=99=E8=AF=AF=E6=97=B6?= =?UTF-8?q?=E6=9C=AA=E8=A7=A6=E5=8F=91onError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-h5/src/api/media/audio/InnerAudioContext.ts | 1 + .../src/api/media/background-audio/BackgroundAudioManager.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts b/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts index f055dc193d4d..f156fd05bfea 100644 --- a/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts +++ b/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts @@ -14,6 +14,7 @@ export class InnerAudioContext implements Taro.InnerAudioContext { this.Instance = new Audio() this.errorStack = new CallbackManager() this.stopStack = new CallbackManager() + this.Instance.onerror = this.errorStack.trigger Taro.eventCenter.on('__taroRouterChange', () => { this.stop() }) this.onPlay(() => { diff --git a/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts b/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts index f62ee0881c43..6044c716fd88 100644 --- a/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts +++ b/packages/taro-h5/src/api/media/background-audio/BackgroundAudioManager.ts @@ -13,6 +13,7 @@ export class BackgroundAudioManager implements Taro.BackgroundAudioManager { this.Instance = new Audio() this.errorStack = new CallbackManager() this.stopStack = new CallbackManager() + this.Instance.onerror = this.errorStack.trigger this.Instance.autoplay = true this.onPlay(() => { if (this.currentTime !== this.startTime) {