美文网首页
小程序背景音乐报错 setBackgroundAudioStat

小程序背景音乐报错 setBackgroundAudioStat

作者: 皇甫圣坤 | 来源:发表于2019-06-27 16:54 被阅读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"

],

相关文章

网友评论

      本文标题:小程序背景音乐报错 setBackgroundAudioStat

      本文链接:https://www.haomeiwen.com/subject/ewwrcctx.html