小王同学xiang
小王同学xiang
  • 发布:2021-07-29 09:45
  • 更新:2021-07-29 09:45
  • 阅读:877

uniapp小程序,视频拍摄问题

分类:HBuilder

您好,最近在做微信小程序的时候遇到了一些问题,我使用的是uniapp框架来开发微信小程序的。遇到的问题是:我在做视频拍摄的时候,在微信开发者工具中调试,能正常拍摄,但是我用 手机调试的时候拍摄不了,也不报错,最后发现我再用cameraContext.stopRecord时,程序并没用走.stopRecord方法。我也不知道什么原因,向大佬们请教一下。
前端绑定的事件如下代码:
<camera v-if="hidden" flash="off" style="width: 100%; height: 100%;position:fixed;top:0;z-index:1111;left:0;"></camera>
<view class="btn-area" >
<view class="">
<text class="videBtn" @touchstart="handleTouchStart" @touchend="handleTouchEnd" v-if="hidden" @longpress="handleLongPress" >按住拍</text>
</view>
</view>

主要事件的代码如下:
//录制视频start
startShootVideo() {
let index = 0;
let that = this
this.timer=setInterval(() => { //注意箭头函数!!
if(that.deflautWidth !=100){
index += 1;
that.deflautWidth = index
}
if (that.deflautWidth == 100) {
clearInterval(this.timer);
}
}, 100);
console.log("========= 调用开始录像 ===========")
this.cameraContext = uni.createCameraContext();
this.cameraContext.startRecord({
success: res => {
console.log("录像成功")
console.log(res)
}
});
},
stopShootVideo() {
console.log("========= 调用结束录像 ===========")
clearInterval(this.timer)
this.cameraContext = uni.createCameraContext();
this.ctx = wx.createCameraContext()
this.cameraContext.stopRecord({
success: res => {
console.log("stopShootVideo")
console.log('结束videoSrc')
this.videoSrc.push(res.tempVideoPath)
console.log(this.videoSrc)
console.log(this.videoSrc)
this.hidden = false
this.showvideoimage = true
}
});
},
// //touch start 手指触摸开始
handleTouchStart(e){
this.starttime = e.timeStamp;
console.log(" startTime = " + e.timeStamp);
console.log(" 手指触摸开始 " , e);
console.log(" this " , this);
},
//touch end 手指触摸结束
handleTouchEnd(e){
clearInterval(this.timer);
this.endtime = e.timeStamp;
// this.stopShootVideo();
// console.log(" endTime = " + e.timeStamp);
console.log(" 手指触摸结束 ", e);
//判断是点击还是长按 点击不做任何事件,长按 触发结束录像
if (this.endtime - this.starttime > 350) {
//长按操作 调用结束录像方法
this.stopShootVideo();
}
this.showProgress = false
this.hidden = false
this.showvideoimage = true
},

        //  * 长按按钮 - 录像  
        handleLongPress(e){  
          console.log("endTime - startTime = "  +  (this.endtime  -  this.starttime));  
          console.log("长按");  
          // 长按方法触发,调用开始录像方法  
          this.startShootVideo();  
        },
2021-07-29 09:45 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复