5 回复
_this.cameraCtx.startRecord({ success() { //添加流 控制时间 let stream = xs .periodic(1000) .endWhen(xs.periodic(11000).take(1)); stream.addListener({ next: i => { _this.countDownTip = "还剩 " + (10 - i) + " 秒" ; _this.$apply(); }, error: err => console.error(err), complete: () => { //录制时间到,停止录制 _this.countDownTip = "还剩 0 秒" ; _this.$apply(); _this.cameraCtx.stopRecord({ success(res) { wx.showLoading({ title: "请稍后……" , mask: true }); //处理视频 _this.$preload( "tempThumbPath" , res.tempThumbPath ); _this.$preload( "tempVideoPath" , res.tempVideoPath ); _this.$redirect({ url: "playvideo" }); wx.hideLoading(); console.log(res); }, fail(res) { wx.showToast({ title: "无法结束录像!" + res.errMessage, icon: "none" }); } }); } }); }, fail(res) { wx.showToast({ title: "无法开始录像!" + res.errMessage, icon: "none" }); } }); |
当中用到了xstream(http://staltz.github.io/xstream/)的库