在微信小程序总播放背景音乐,现在已经是很方便的事情了。
const backgroundAudioManager = wx.getBackgroundAudioManager()
backgroundAudioManager.title = '此时此刻'
backgroundAudioManager.epname = '此时此刻'
backgroundAudioManager.singer = '许巍'
backgroundAudioManager.coverImgUrl = 'https://www.zhuige.com/uploads/20221105/dbd7dd97224c5d16482ee9cc76d378b6.jpg'
// 设置了 src 之后会自动播放
backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
其中,必须要设置的属性是 title 和 src。
还需要注意,在 app.json 中做好相关权限的配置,如下:
"requiredBackgroundModes": ["audio"]
-
微信小程序打开任意公众号文章 wx.openOfficialAccountArticlewx.openOfficialAccountArticle是微信小程序通过小程序打开任意公众号文章api,不包括临时链接等异常状态下的公众号文章,必须有点击行为才能调用成功。
-
wx.onBatteryInfoChange 监听电池信息变化事件 APIwx.onBatteryInfoChange 为微信小程序监听电池信息变化事件 API,,目前只支持监听省电模式的切换,目前仅 iOS 端支持。
-
live-pusher 实时音视频录制媒体组件live-pusher 微信小程序实时音视频录制媒体组件,v2.9.1 起支持同层渲染。需要用户授权 scope.camera、scope.record。
-
open-container容器转场动画组件open-container为微信小程序容器转场动画组件。
-
wx.setStorage 将数据存储在本地缓存中指定的 key 中微信小程序wx.setStorage 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
-
微信小程序wx.getExtConfig 的同步版本 APIwx.getExtConfig 为微信小程序的同步版本 API。
暂无评论,抢个沙发...