lypeer / wechat-weapp-gank

746 stars 144 forks source link

请教一个问题:小程序保存的音频文件如何调用播放,谢谢 #3

Open guoxiangke opened 7 years ago

guoxiangke commented 7 years ago

var music_url = 'http://yinyueshiting.baidu.com/data2/music/122873158/49046814400128.mp3?xcode=4e68ea1f9b0fc6c384b505fb6b038464' wx.downloadFile({ url: music_url, type: 'audio', fail: function(res){ console.log(res,'downloadFile.fail') }, success: function(res) { var tempFilePath = res.tempFilePath wx.playBackgroundAudio({//不行! dataUrl: tempFilePath }) console.log(tempFilePath,'res.tempFilePath') wx.saveFile({ tempFilePath: tempFilePath, success: function(res) { wx.playBackgroundAudio({//也不行! dataUrl: res.savedFilePath }) } }) }, })

lypeer commented 7 years ago

目前可能由于是在内测的原因,下载这个接口暂时是不能用的,你可以打断点看看,在调用了下载接口之后小程序既不会进入 fail 也不会进入 success ,这也就是导致你写的方法不成功的原因。解决方法的话,要么你可以直接播放一段音频,要么就只能等开放公测再试试喽~