Michael Wang 6 жил өмнө
parent
commit
a6595302f9

+ 8 - 4
src/components/FaceRecognition/FaceRecognition.vue

@@ -111,6 +111,7 @@ export default {
       try {
         const examRecordDataId = this.$route.params.examRecordDataId;
         const captureBlob = await this.getSnapShot();
+        this.videoStartPlay();
         // console.log(captureBlob.size);
         this.serverLog("debug/S-004001", "抓拍照片的大小:" + captureBlob.size);
         const captureFilePath = await this.uploadToServer(captureBlob);
@@ -119,11 +120,14 @@ export default {
         // FIXME: more processing
         console.log("定时抓拍流程失败");
       } finally {
-        const video = this.$refs.video;
-        video && video.play();
+        this.videoStartPlay();
         this.decreaseSnapCount();
       }
     },
+    videoStartPlay() {
+      const video = this.$refs.video;
+      video && video.play();
+    },
     async snap() {
       // TODO: chrome 70. FaceDetector检测人脸
       // var canvas = document.createElement("canvas");
@@ -151,6 +155,7 @@ export default {
         // if(this.disableSnap) return; // 避免界面没有更新。
         this.msg = "拍照中...";
         const captureBlob = await this.getSnapShot();
+        this.videoStartPlay();
         this.msg = "上传照片中...";
         const captureFilePath = await this.uploadToServer(captureBlob);
         this.msg = "人脸比对中...";
@@ -160,8 +165,7 @@ export default {
         console.log("同步照片比对流程失败");
         throw error;
       } finally {
-        const video = this.$refs.video;
-        video && video.play();
+        this.videoStartPlay();
         this.msg = "开始识别";
         this.disableSnap = false;
       }