const innerAudioContext = wx.createInnerAudioContext() //创建实例 innerAudioContext.autoplay = true //是否自动 innerAudioContext.loop = true //是否循环 innerAudioContext.src = 'https://scantest.leting360.cn/codeCall/phone.mp3' innerAudioContext.onPlay(() => { console.log('开始播放') }) innerAudioContext.onError((res) => { console.log("播放失败") console.log(res) }) innerAudioContext.stop()//停止
API意义在于可以在页面load时候调用,而组件却不行
// wx.playBackgroundAudio({ // dataUrl: "https://scantest.leting360.cn/codeCall/phone.mp3", // title: '', // coverImgUrl: '' // }) //播放背景音乐