onBackgroundAudioStop callback的bug
发布于 6 年前 作者 wanjuan 3811 次浏览 来自 问答

代码如下:

wx.onBackgroundAudioStop(function(res) {

      console.log("In auto stop: ", res)

      console.log(“this data”, this)

      wx.playBackgroundAudio({

        dataUrl: res.dataUrl,

      })

    })

在开发编辑器中res是有数据的,但是在手机上跑res是个空的,是小程序的bug?

  1. 这里的function(res)里的res参数我们可以自定义传入吗?有的话,应该怎么写,求指教!
2 回复

文档中 callback 的 res 是不带有任何参数的,手机上的实现才是正确的,开发者工具中的问题我确认下

在页面销毁的时候调用 onBackgroundAudioStop(nulll)出现崩溃。

WAService.js:3 thirdScriptError

Cannot read property ‘apply’ of null;at pages/story/play/play onUnload function;at onBackgroundAudioStop callback function

TypeError: Cannot read property ‘apply’ of null

    at .<anonymous> (http://687585042.appservice.open.weixin.qq.com/WAService.js:3:7221)

    at http://687585042.appservice.open.weixin.qq.com/WAService.js:4:27744

    at n.<anonymous> (http://687585042.appservice.open.weixin.qq.com/asdebug.js:1:12260)

    at n.emit (http://687585042.appservice.open.weixin.qq.com/asdebug.js:1:8658)

    at r (http://687585042.appservice.open.weixin.qq.com/asdebug.js:1:1494)

    at g (http://687585042.appservice.open.weixin.qq.com/asdebug.js:1:4855)

回到顶部