|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
- <view class="zhuapai-drop-container" id="Drop" ref="DropRef" :style="style" @touchmove="touchmove($event)" @touchstart="touchstart($event)">
|
|
|
+ <view class="zhuapai-drop-container" id="Drop" ref="DropRef" :style="style" @touchmove="touchmove($event)"
|
|
|
+ @touchstart="touchstart($event)">
|
|
|
<view class="phone-camera-box-zhuapai">
|
|
|
<video ref="videoRef" class="video-view-box" :class="myClass" id="videoZhaPai" :controls="false"></video>
|
|
|
<!-- 隐藏抓拍绘制图片 -->
|
|
@@ -44,6 +45,9 @@
|
|
|
const disX = ref(0); // 移动x
|
|
|
const disY = ref(0); // 移动y
|
|
|
const showVideo = ref(true);
|
|
|
+ const isBuffer = ref(false);
|
|
|
+
|
|
|
+ const stopTimer = ref(null);
|
|
|
const style = ref({
|
|
|
top: "10vh",
|
|
|
right: "0",
|
|
@@ -56,7 +60,7 @@
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- const emits = defineEmits(['init', 'success', 'error', 'cancel'])
|
|
|
+ const emits = defineEmits(['init', 'success', 'error', 'cancel', 'progress'])
|
|
|
|
|
|
function noShowVideoBtn() {
|
|
|
showVideo.value = false
|
|
@@ -71,10 +75,10 @@
|
|
|
// 2,获取手指移动的实时位置 需要减去位置差
|
|
|
let moveX = event.touches[0].pageX - disX.value;
|
|
|
let moveY = event.touches[0].pageY - disY.value;
|
|
|
-
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- const windowHeight = systemInfo.windowHeight; // 可视区域高度 :ml-citation{ref="1,3" data="citationList"}
|
|
|
- const windowWidth = systemInfo.windowWidth; // 可视区域高度 :ml-citation{ref="1,3" data="citationList"}
|
|
|
+
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+ const windowHeight = systemInfo.windowHeight; // 可视区域高度 :ml-citation{ref="1,3" data="citationList"}
|
|
|
+ const windowWidth = systemInfo.windowWidth; // 可视区域高度 :ml-citation{ref="1,3" data="citationList"}
|
|
|
|
|
|
|
|
|
// 3,获取容器的宽高和拖动元素的宽高 每一次移动都会获取一次 ,建议放在外面进行获取
|
|
@@ -157,42 +161,136 @@
|
|
|
// 首次运行进行抓拍一次
|
|
|
handleZhua();
|
|
|
}, 3000);
|
|
|
+ addVideoListener();
|
|
|
}
|
|
|
|
|
|
function onVideoError() {
|
|
|
emits('error')
|
|
|
+ removeVideoListener()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 针对视频通话的监听处理
|
|
|
+
|
|
|
+ function onTimeupdate() {
|
|
|
+ if (isBuffer.value) {
|
|
|
+ console.log('buffer')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!stopTimer.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log('onTimeupdate')
|
|
|
+ clearTimeout(stopTimer.value);
|
|
|
+ stopTimer.value = null;
|
|
|
}
|
|
|
|
|
|
+ function onProgress() {
|
|
|
+ if (stopTimer.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isBuffer.value = true;
|
|
|
+ console.log('onProgress')
|
|
|
+ // buffer时间增大到3秒 过滤掉后续的onTimeupdate
|
|
|
+ setTimeout(() => {isBuffer.value = false}, 3000)
|
|
|
+ // 视频中途暂停被占用
|
|
|
+ stopTimer.value = setTimeout(() => {
|
|
|
+ emits('progress', false);
|
|
|
+ console.log('结束')
|
|
|
+ }, 10 * 1000)
|
|
|
+ }
|
|
|
+ function addVideoListener() {
|
|
|
+ let video = document.querySelector(`#videoZhaPai .uni-video-video`)
|
|
|
+ // 判定有流
|
|
|
+ video.addEventListener('progress', onProgress);
|
|
|
+ video.addEventListener('timeupdate', onTimeupdate);
|
|
|
+ }
|
|
|
+ function removeVideoListener() {
|
|
|
+ let video =document.querySelector(`#videoZhaPai .uni-video-video`)
|
|
|
+ video && video.removeEventListener('progress', onProgress);
|
|
|
+ video && video.removeEventListener('timeupdate', onTimeupdate);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
onUnmounted(() => {
|
|
|
// 组件销毁时停止摄像头
|
|
|
stopCamera && stopCamera();
|
|
|
+ removeVideoListener();
|
|
|
})
|
|
|
|
|
|
defineExpose({
|
|
|
- init,showVideoBtn
|
|
|
+ init,
|
|
|
+ showVideoBtn
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
.zhuapai-drop-container {
|
|
|
- width: 180rpx;height: 400rpx;margin: 0;padding: 0;z-index: 10;position: absolute;overflow: hidden;
|
|
|
- .phone-camera-box-zhuapai{
|
|
|
- width: 100%;height: 240rpx;position: absolute;overflow: hidden;
|
|
|
- .uni-video-container{background-color: transparent; pointer-events: none;}
|
|
|
- .canvas-view-box,.hidden-video{transform: translateY(10000rpx);}
|
|
|
+ width: 180rpx;
|
|
|
+ height: 400rpx;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ z-index: 10;
|
|
|
+ position: absolute;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .phone-camera-box-zhuapai {
|
|
|
+ width: 100%;
|
|
|
+ height: 240rpx;
|
|
|
+ position: absolute;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .uni-video-container {
|
|
|
+ background-color: transparent;
|
|
|
+ pointer-events: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .canvas-view-box,
|
|
|
+ .hidden-video {
|
|
|
+ transform: translateY(10000rpx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .video-view-box {
|
|
|
+ width: 100%;
|
|
|
+ height: 240rpx;
|
|
|
+ position: absolute;
|
|
|
+ }
|
|
|
+
|
|
|
+ .shiti-video-hidden-btn,
|
|
|
+ .shiti-video-show-btn {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+
|
|
|
+ i {
|
|
|
+ width: 32rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ display: block;
|
|
|
+ background-size: cover;
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center;
|
|
|
+ }
|
|
|
}
|
|
|
- .video-view-box{width:100%;height: 240rpx;position: absolute;}
|
|
|
- .shiti-video-hidden-btn,.shiti-video-show-btn{
|
|
|
- position: absolute;top:0;
|
|
|
- i{width: 32rpx;height: 32rpx;display: block;background-size: cover;background-repeat: no-repeat;background-position:center;}
|
|
|
+
|
|
|
+ .shiti-video-hidden-btn {
|
|
|
+ width: 60rpx;
|
|
|
+ height: 60rpx;
|
|
|
+ left: 0;
|
|
|
+
|
|
|
+ i {
|
|
|
+ background-image: url("@/static/images/exam/video-close-icon.svg");
|
|
|
+ margin: 6rpx auto 6rpx 6rpx;
|
|
|
+ }
|
|
|
}
|
|
|
- .shiti-video-hidden-btn{
|
|
|
- width: 60rpx;height: 60rpx;left:0;
|
|
|
- i{background-image: url("@/static/images/exam/video-close-icon.svg");margin:6rpx auto 6rpx 6rpx;}
|
|
|
- }
|
|
|
- .shiti-video-show-btn{
|
|
|
- background-color: #dcfbf1;padding:20rpx;border-radius:8rpx;right:0;
|
|
|
- i{background-image: url("@/static/images/exam/video-play-icon.svg");}
|
|
|
+
|
|
|
+ .shiti-video-show-btn {
|
|
|
+ background-color: #dcfbf1;
|
|
|
+ padding: 20rpx;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ right: 0;
|
|
|
+
|
|
|
+ i {
|
|
|
+ background-image: url("@/static/images/exam/video-play-icon.svg");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|