录音文件上传到服务器后然后再下载调用playVoice播放没有声音
发布于 6 年前 作者 lwen 17036 次浏览 来自 问答
play: function (e) {
   var path = e.target.dataset.path;
   var that = this
   that.setData({
     ifplay:false
   })
   wx.downloadFile({
     url: path,
     success: function (res) {
       console.log("download tmpfile path is:",res.tempFilePath)
       wx.playVoice({
         filePath: res.tempFilePath,
         success:function(){
           console.log('play voice success')
         },
         fail:function(errMsg){
           console.log('play file fail, errMsg is', errMsg)
         },
         complete:function(){
           console.log('play voice complete')
           that.setData({
             ifplay:true
           })
         }
       })
     },
     fail: function (errMsgres) {
       console.log('download file fail, errMsg is', errMsg)
     }
   })
 }

模拟器环境调试,录音文件已成功上传到后台,下载完后后播放下载的录音文件会触发success()和complete()方法,但是没有声音,而且success()和complete()方法是很快触发的,就像播放了一下立刻就结束了

下面是控制台输出

回到顶部