//app.js onLaunch: function () { console.log(this) this.AppMusic = wx.createInnerAudioContext(); this.AppMusic.autoplay = true; this.AppMusic.loop = true; this.AppMusic.onPlay(() => { console.log('开始播放') }) this.AppMusic.onError((res) => { console.log(res.errMsg) console.log(res.errCode) }) }, //你要播放的界面,加载音乐链接 // 从60s开始播放 app.AppMusic.seek(60); app.AppMusic.src = 'http://ovhvevt35.bkt.clouddn.com/photo/%E5%A5%BD%E5%A6%B9%E5%A6%B9%E4%B9%90%E9%98%9F%20-%20%E4%B8%8D%E8%AF%B4%E5%86%8D%E8%A7%81.mp3' // music music(e){ let that = this; let status = e.currentTarget.dataset.status; if (status){ app.AppMusic.pause(); app.AppMusic.onPause(() => { console.log('暂停播放'); that.setData({ status: false }) }) }else{ app.AppMusic.play(); app.AppMusic.onPlay(() => { console.log('开始播放'); that.setData({ status: true }) }) } console.log(e) }, // 上传图片音乐会暂停 upImg(){ wx.chooseImage({ success: function (res) { var tempFilePaths = res.tempFilePaths wx.uploadFile({ url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址 filePath: tempFilePaths[0], name: 'file', formData: { 'user': 'test' }, success: function (res) { var data = res.data //do something } }) } }) },