diff --git a/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts b/packages/taro-h5/src/api/media/audio/InnerAudioContext.ts index c877b8b8c0ff..cfa5fe629916 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) {