收藏
回答

播放不了已经下载成功的临时文件,Why?

问题模块
API和组件
downloadFile : function(){
    var that = this;
    const downloadTask = wx.downloadFile({
      url: 'http://mp3.flash127.com/Uploads/201708/20170810_1819_170614.mp3',
      success: function(res){
        wx.playVoice({
            filePath: res.tempFilePath,
            success : function(res){
                console.log(res);
            },
            fail : function(){
                console.log("Error!");
            },
            complete : function(){}
        });
      },
      fail : function(){
        console.log("Error!");
      },
      complete : function(){}
  });
    downloadTask.onProgressUpdate((res) => {
        that.setData({
            downloadFileProgress: res.progress
        });
        console.log('下载进度', res.progress)
        console.log('已经下载的数据长度', res.totalBytesWritten)
        console.log('预期需要下载的数据总长度', res.totalBytesExpectedToWrite)
    });
    //downloadTask.abort();
}


最后一次编辑于  2017-08-28  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏关注问题回答

2 个回答

  • 晨
    2017-08-29

    playVoice 只能播放录音文件

    2017-08-29
    赞同
    回复
  • Simon.Chen
    Simon.Chen
    2017-09-11

    同问

    function play(url) {

        wx.playBackgroundAudio({

            dataUrl: url

        });

        console.log(url);

        wx.onBackgroundAudioStop(function () {

            wx.playBackgroundAudio({

                dataUrl: url

            });

        });

    }


    下载的临时文件不能播放?

    我在console里面打出来点击链接可以播放,但是调用play方法不能播放


    2017-09-11
    赞同
    回复