wx.createInnerAudioContext()停止播放

发布于 8 年前作者 nashen9373 次浏览最后编辑 8 年前来自 ask

我想在页面启动的时候,播放音频,成功了

onLoad: function(options) {
    const innerAudioContext = wx.createInnerAudioContext()
    innerAudioContext.src = options.url
    innerAudioContext.play()
},

想在卸载页面时,停止,但是失败了

onUnload: function() {
    const innerAudioContext = wx.createInnerAudioContext()
    innerAudioContext.stop()
    innerAudioContext.destroy()
},

我猜想可能不是一个实例了,但是该如何解决呢?0.0

1 回复
minsun
minsun1 楼6 年前

那你把 const innerAudioContext = wx.createInnerAudioContext() 写在Page({})外层呢