开始录制: start_recorder: function () { this.ctx = wx.createCameraContext(); let time = this.data.camera.timeout; let that = this; recorder_time_start = new Date().getTime(); this.ctx.startRecord({ timeout: time, success: (res) => { console.log('startRecord') console.log(res); this.setData({ button: 2 }); }, timeoutCallback: (res) => { console.log('录制超时') console.log(res); wx.showToast({ title: '录制超时', icon: 'error', duration: 2000 }); this.stop_recorder(); }, fail: (err) => { console.log(err); //wx.showToast({ title: JSON.stringify(err), icon: 'error', duration: 2000 }); setTimeout(() => { this.start_recorder(); }, 2000); }, complete: (res) => { console.log('调用完成') } }); }, 停止录制: stop_recorder: function () { console.log('test:', '::', 'stop') wx.showLoading({ title: '正在停止录制并压缩...', mask: true }); clearInterval(listener_interval); listener_interval = null; clearInterval(obj_interval); obj_interval = null; this.ctx.stopRecord({ compressed: true, success: (res) => { console.log('保存结果', res); wx.hideLoading({}); if (1 == stop_recorder_state) { let target = '/pages/record/answer'; wx.navigateTo({ url: target }); return; } let index = app.globalData.index; let question = app.globalData.investigation.question; let last = index == (question.length - 1); app.globalData.investigation.question[index].duration = this.data.count; this.setData({ imageSrc: res.tempThumbPath, videoSrc: res.tempVideoPath, stopbutton: false, button: 3, component: 2, counttext: '00:00', count: 0, last: last }); }, fail: (err) => { console.log('停止错误:', err); wx.showToast({ title: JSON.stringify(err), icon: 'error', duration: 2000 }); wx.hideLoading({}); }, complete: (res) => { console.log('停止完成', res) } }); },
为啥CameraContext.stopRecord在PC端不返回tempVideoPath ?为啥CameraContext.stopRecord在PC端不返回tempVideoPath?在模拟器、真机均会返回 tempThumbPath和tempVideoPath属性 模拟器 [图片] 真机 [图片] PC端则没有 [图片]
03-12