wx.saveFile保存文件失败是什么情况
发布于 5 年前 作者 iguo 16495 次浏览 来自 问答
startRecord: function () {
    var that = this;
    // wx.showToast({
    //   title: '已开始录音',
    //   icon: 'success',
    //   duration: 2000
    // })
    wx.startRecord({
      success: function (res) {
        tempFilePath = res.tempFilePath;
        wx.saveFile({
          tempFilePath: tempFilePath,
          success: function (res) {
            // success
            savedFilePath = res.savedFilePath;
            var info_v = new Info();
            info_v.path = savedFilePath;
            info_v.mode = "voice";
            info_v.time = util.formatTime(new Date());
            // info_v.getSize();
            wx.getSavedFileInfo({
              filePath: savedFilePath,
              success: function (res) {
                // success
                info_v.size = (res.size / 1024).toFixed(2) + "Kb";
                console.log(info_v);
                infos.push(info_v);
                that.setData({
                  arr_info: infos,
                })
                console.log(infos);
              },
              fail: function () {
                // fail
              },
            })
            // info_v.size = getSize.getS(savedFilePath);
          },
          fail: function () {
            // fail
            console.log("fail")
          },
        })
      },
      fail: function (res) {
        //录音失败
      }
    })
  },
  stopRecord: function () {
    // wx.hideToast();
    wx.stopRecord();
  },

在模拟器上可以正常保存,在ios手机则输出命令行:fail,之前保存图片也有类似问题,换临时路径规避了,可这个就郁闷了

回到顶部