Pārlūkot izejas kodu

新活检结束,关闭摄像头

Michael Wang 5 gadi atpakaļ
vecāks
revīzija
7f1967d625

+ 11 - 0
src/features/OnlineExam/Examing/FaceMotion/FaceMotion.vue

@@ -316,6 +316,7 @@ export default {
     this.run();
     this.run();
   },
   },
   beforeDestroy() {
   beforeDestroy() {
+    this.closeCamera();
     this.$Spin.hide();
     this.$Spin.hide();
   },
   },
   methods: {
   methods: {
@@ -1051,6 +1052,16 @@ export default {
         throw "同步照片比较失败!";
         throw "同步照片比较失败!";
       }
       }
     },
     },
+    closeCamera: function() {
+      console.log("关闭摄像头");
+      const video = document.getElementById("inputVideo");
+      if (video.srcObject) {
+        video.srcObject.getTracks().forEach(function(track) {
+          track.stop();
+        });
+        video.srcObject.srcObject = null;
+      }
+    },
   },
   },
 };
 };
 </script>
 </script>