var bgm = wx.createInnerAudioContext()bgm.autoplay = truebgm.loop = truebgm.src = "res/hall_background_music.mp3"wx.onShow(function (options) { console.log("onShow") bgm.play();}); |
小游戏打开时马上播放背景音乐,双击 Home 键切换到任务列表,音乐被暂停(停止)。 回到小游戏,音乐无法恢复。 onShow 事件并没有被触发。
这个问题要怎么处理?

这样试试:
wx.onAudioInterruptionEnd(() => {
bgm.play();
})
wx.onShow(() => {
bgm.play();
})