小程序背景音乐报错 setBackgroundAudioStat

2019-06-27  本文已影响0人  皇甫圣坤

设置title后即可修复

// music.js

 properties: {

   src: String,

   title: String

 },
// ...省略
      const mMgr = wx.getBackgroundAudioManager()

       mMgr.src = this.properties.src

       mMgr.title = this.properties.title

此外,classic.wxml添加一下:

<v-music 
    wx:if="{{classic.type==200}}" 
    img="{{classic.image}}"
    content="{{classic.content}}"
    title="{{classic.title}}" 
    src="{{classic.url}}" />

注意:可能还会报一个:若需要小程序在退到后台后继续播放音频,你需要在 app.json中配置 requiredBackgroundModes属性,详见: https://developers.weixin.qq.com/miniprogram/dev/framework/config.html#requiredbackgroundmodes 错误

那就在外面的app.json里添加:

"requiredBackgroundModes": [

"audio"

],
上一篇 下一篇

猜你喜欢

热点阅读