The WeChat applet cameraContext.stopRecord does not report an error or respond

In the past two days, I encountered a strange problem. The cameraContext object obtained through wx.createCameraContext();

There is no problem executing cameraContext.startRecord,

However, the execution of cameraContext.stopRecord does not report an error or respond,

It's a headache, and there is very little information on WeChat. After researching for a long time, I found that it was affected by this.setData.

Whether setData is executed before cameraContext.stopRecord,

Or execute cameraContext.stopRecord in the callback function of setData,

Neither can.

If setData is really needed, it can only be placed in the callback function after cameraContext.stopRecord succeeds.

stopRecord() {
    console.log("stopRecord, this.data.num ="+this.data.num);
    if (this.data.isStop){ //说明已结束
        return;
    }
    wx.showLoading({
      title: '视频处理中',
      mask: true
    });
    this.end(this);
  },
  end(that) {
    console.log("that",that);
    console.log("that.cameraContext.webviewId="+that.cameraContext.webviewId);
    console.log("that.cameraContext._isRecording2="+that.cameraContext._isRecording);
    that.cameraContext.stopRecord({
      compressed: true, //压缩视频
      success: (res) => {
        console.log("stopRecord success", res);
        that.setData({
          src: res.tempThumbPath,
          videoSrc: res.tempVideoPath,
          num: 0,
          isStart: false,
          isStop: true,
        });
        wx.hideLoading();
      },
      fail: (e) => {
        console.log("stopRecord fail", e);
        wx.showLoading({
          title: '异常请重试',
        })
      },
      complete: (res) => {
        console.log("stopRecord complete", res);
      }
    });
  },

Guess you like

Origin blog.csdn.net/u013282737/article/details/128633784