- 小程序安卓熄屏状态下无法给getBackgroundAudioManager赋值
表现:安卓客户端熄屏状态下无法播放下一首声音,报错 已经设置后台阔以播放配置的前提下, "requiredBackgroundModes": [ "audio" ] 小程序监听播放完成事件,触发下一首播放逻辑,播放逻辑主要是给backgroundAudioManager设置新资源 const backgroundAudioManager = wx.getBackgroundAudioManager() Page({ data: { img: "", title: "", singer: "", isPlay: false, index: 0, currentSource: {}, list: [ { id: 589322102, title: "开篇", albumId: 3595841, albumName: 'cppp', albumTitle: "", cover: "https://imagev2.xmcdn.com/group54/M03/BE/89/wKgLclw1y2PjEND8AAGN2SKPPNM391.jpg!op_type=3&columns=290&rows=290", src: "https://aod.cos.tx.xmcdn.com/group62/M03/C8/9F/wKgMZ10CGTOzvH2PAAWkNYbQNNE614.m4a", }, { id: 588766344, title: "第一首", intro: "", albumName: 'www', albumId: 3595841, albumTitle: "", cover: "https://imagev2.xmcdn.com/storages/908e-audiofreehighqps/EB/3E/GMCoOR4HTROmAAZkOAHOdIR8.jpeg", src: "https://aod.cos.tx.xmcdn.com/group62/M07/C8/99/wKgMcV0CGOCTGc4zAAMNLnb_ZI0380.m4a", }, { title: "第二首", intro: "", albumName: 'whmhhh', albumId: 3595841, albumTitle: "", cover: "https://imagev2.xmcdn.com/storages/8e37-audiofreehighqps/0B/C7/GMCoOSYHSmcmAAwXEwHMq3Jp.jpeg", src: "https://aod.cos.tx.xmcdn.com/group62/M07/C8/92/wKgMcV0CGMewDkbUAAGoaM7zIss224.m4a", } ], }, onLoad: function (options) { this.getData(); this.init() }, init() { backgroundAudioManager.onEnded(() => { this.nextplay(); }) }, getData: function () { const { list, index } = this.data const currentSource = list[index] this.setData({ currentSource: currentSource }) this._initAudioManager(currentSource); }, // 设置资源 _initAudioManager({ src = '', title = '', albumName = '', singer = '', cover = '', protocol = 'http', } = {}) { backgroundAudioManager.title = ` ${title ? title : albumName}`; backgroundAudioManager.epname = albumName; backgroundAudioManager.singer = singer; backgroundAudioManager.coverImgUrl = cover; backgroundAudioManager.src = src; backgroundAudioManager.protocol = protocol; }, //点击播放 playmp3: function () { var that = this; console.log(backgroundAudioManager, 'backgroundAudioManager') if (this.data.isPlay) { backgroundAudioManager.play(); } else { backgroundAudioManager.pause(); } that.setData({ isPlay: !this.data.isPlay }) }, nextplay: function () { wx.showToast({ title: '即将播放下一首', icon: "none", duration: 1000, }) let { list, index } = this.data const currentSource = list[index + 1] this.setData({ index: index + 1, currentSource: currentSource }) this._initAudioManager(currentSource); }, }) 现在遇到安卓客户端在熄屏状态下无法自动进行下一首的播放,开发工具查看,会报错 setBackgroundAudioState:fail: jsapi has no permission, event=setBackgroundAudioState, runningState=background, permissionMsg=permission ok, detail=jsapi permission required playing audio but current not playing audio in background state 其他家像懒人听书/蜻蜓在熄屏状态下表现也是一样的,无法播放下一首,上周四之前还是好的
2022-11-21 - oppo微信小程序客户端,音频资源播放不了,报错, errCode: -1
[图片] 问题:oppo微信小程序客户端,音频资源播放不了,报错 复现步骤: oppo安卓手机打开喜马拉雅微信小程序,搜索‘名人话航模’,点击第一个声音,然后进到声音页,这时候正常来说是能播放的,但是这个专辑下的声音不能播放,微信IDE是能播放的,安卓端不行 基础库: 2.23.4 API: wx.getBackgroundAudioManager() 播放音频资源,有几个资源真机播放不了,打印报错, error: { errCode: -1 errMsg: "errCode:-1, err:unknow exception" src: "https://aod.cos.tx.xmcdn.com/storages/3c42-audiofreehighqps/C4/06/GKwRIDoGqSTvAK3fbQGAkgAH.m4a" } 播放资源如果换成‘https://aod.cos.tx.xmcdn.com/storages/669b-audiofreehighqps/95/BB/GKwRIJIG334GAB68HQGYVaM9.m4a’就能播放 [图片]
2022-08-29 - 微信小程序wx.getBackgroundAudioManager()有的音频资源播放不了?
[图片] 问题:微信环境小程序里,音频资源播放不了,报错 基础库: 2.23.4 API: wx.getBackgroundAudioManager() 播放音频资源,有几个资源真机播放不了,打印报错, error: { errCode: -1 errMsg: "errCode:-1, err:unknow exception" src: "https://aod.cos.tx.xmcdn.com/storages/3c42-audiofreehighqps/C4/06/GKwRIDoGqSTvAK3fbQGAkgAH.m4a" } 播放资源如果换成‘https://aod.cos.tx.xmcdn.com/storages/669b-audiofreehighqps/95/BB/GKwRIJIG334GAB68HQGYVaM9.m4a’就能播放 [图片]
2022-08-29