playvoice怎么播放来自服务器的音频?

发布于 7 年前作者 wanchao10048 次浏览最后编辑 7 年前来自 ask

    wx.playVoice({

      filePath: that.data.http + FilePath,

      success: function () {

        console.log( ‘播放录音’ )

      },

      fail: function () {

        console.log( ‘播放失败’ )

      }

    });

一直走fail

7 回复
gongyong
gongyong1 楼6 年前

@Link 先下载,在拿得到的地址去播放,确实走了success,但是完全没有声音啊,怎么破

xiexiulan
xiexiulan2 楼6 年前

同问

wfeng
wfeng3 楼6 年前

我也遇到了先下载,在拿得到的地址去播放,确实走了success,但是完全没有声音啊,怎么破。有人解决了吗?

    var url = ‘http://ot0t7lbj0.bkt.clouddn.com/1510035399777.amr?e=1510039013&token=Qt8wTRR\_kJdyK8q1z0DrYB8iufe9bgiFBeUHhMxR:IEz8cu99NiO8coS-pmv0tJW2r6E=

    wx.downloadFile({

      url: url,

      success: function (res) {

        console.log(res.tempFilePath)

        wx.playVoice({

          filePath: res.tempFilePath,

          success:function(res) {

            console.log(res)

          },

          complete: function (res) {

            console.log(‘playVoice res’)

            console.log(res)

          }

        })

      }

    })

打印地址:

wxfile://tmp_388763900o6zAJs9YVxP64hKIK5Dc11Lwmg7sf83d83bd75ecb66dc4732dae1659b9bc.amr

index.js [sm]:108 Object {errMsg: “playVoice:ok”}

index.js [sm]:111 playVoice res

index.js [sm]:112 Object {errMsg: “playVoice:ok”}

yutao
yutao4 楼6 年前

我的是下载后的声音首播没问题。暂停后再拨就没声音了。

juanguo
juanguo5 楼6 年前

先调用 downloadFile ,拿到 tempFilePath ,再用这个 tempFilePath 去播放

qiang46
qiang466 楼6 年前

我也遇到了先下载,在拿得到的地址去播放,确实走了success,但是完全没有声音啊,怎么破

xlei
xlei7 楼5 年前

先下载,在拿得到的地址去播放,确实走了success,但是完全没有声音啊,怎么破