Browse Source

允许关闭监控

y595705120 1 year ago
parent
commit
2c23e48fcc

+ 2 - 2
config/index.js

@@ -2,9 +2,9 @@
 // Template version: 1.3.1
 // see http://vuejs-templates.github.io/webpack for documentation.
 //
-// const TARGET = "http://study.ndjsxh.cn:8888/"
+const TARGET = "https://edu.hqedust.com:18443/"
 // const TARGET = "http://localhost:8000/"
-const TARGET = "https://edu.hqedust.com/"
+// const TARGET = "https://edu.hqedust.com/"
 const path = require('path')
 
 module.exports = {

+ 20 - 36
src/containers/center/play/components/iMedia.vue

@@ -6,7 +6,7 @@
       <span>{{media.duration|useTime}}</span>
     </h2>
     <el-row style="width: 900px;">
-      <el-col :span="8" style="width: 250px;">
+      <el-col :span="8" style="width: 250px;" v-show="!closeFace">
         <video ref="video" v-show="isnotbtn" width="240" height="180" autoplay></video>
         <canvas ref="canvas" v-show="ontakebtn" width="240" height="180"></canvas>
       </el-col>
@@ -56,32 +56,7 @@
     components: {
       videoPlayer
     },
-    watch: {
-      mediaType() {
-        if (!this.mediaType) return;
-      }
-    },
-    props: {
-      mediaType: {
-        type: String,
-        default: ''
-      },
-      media: {
-        type: Object,
-        default: () => {
-          return {
-            id: '',
-            percent: 0
-          }
-        }
-      },
-      options: {
-        type: Object,
-        default: () => {
-          return {}
-        }
-      }
-    },
+    props: [ 'media', 'options', 'heartbeat', 'maxErrorCount', 'collectBeat','closeFace'],
     filters: {
       useTime(val) {
         let timestr = ""
@@ -147,6 +122,10 @@
       },
       callCamera() {
         // H5调用电脑摄像头API
+        if( this.closeFace){
+          this.isnotbtn = true;
+          return;
+        }
         navigator.mediaDevices
           .getUserMedia({
             video: true,
@@ -265,6 +244,7 @@
         this.reportErr("play", 'start');
         this.startTick();
         this.onPlay = true
+        this.tickNum = 0 
       },
       reportErr(action, msg) {
         httpServer("course.report", {
@@ -293,28 +273,32 @@
           console.log("finish")
           return;
         }
+        console.log(this.heartbeat, this.collectBeat, this.closeFace)
 
-        if (!this.isnotbtn && this.onPlay) {
+        if (!this.isnotbtn && !this.media.isFinish && this.onPlay && !this.closeFace) {
           this.$message.errorMsg("需要安装摄像头才能学习", 2);
           this.doPause()
           return;
         }
-        if (this.errCount > 5) {
+        if (this.errCount >= this.maxErrorCount) {
           this.$message.errorMsg("人脸不在摄像头上", 5);
           this.destroyTimer()
           this.$emit("close");
           return;
         }
-        // 异常 10秒检查
-        if (this.errCount > 0 && this.tickNum % 10 == 3) {
-          this.photograph()
-        } else if (this.tickNum % 60 == 1) {
-          this.photograph()
-        }
         // 每5秒一次心跳
-        if (this.tickNum % 5 != 0) {
+        if (this.tickNum % this.heartbeat != 1) {
           return;
         }
+        let heartBeat = parseInt( this.tickNum / this.heartbeat);
+        // 异常 10秒检查
+        if( !this.closeFace ){
+          if (this.errCount > 0 ) {
+            this.photograph()
+          } else if ( heartBeat % this.collectBeat == 1) {
+            this.photograph()
+          }
+        }
         // 主动暂停
         let myPlayer = this.$refs.videoPlayer.player;
         let curTimes = parseInt(myPlayer.currentTime());

+ 13 - 0
src/containers/center/play/index.vue

@@ -89,6 +89,10 @@
               :duration="info.duration"
               @close="closeMedia"
               :mediaType="mediaType"
+              :heartbeat="heartbeat"
+              :max-error-count="maxErrorCount"
+              :collect-beat='collectBeat'
+              :close-face="closeFace"
               @changeMedia="changeMedia"
               @updateOption = "updateOption"
               @update="update">
@@ -150,6 +154,10 @@
         page:1,
         size:5,
         mediaId:0,
+        heartbeat:5,
+        maxErrorCount:20,
+        collectbeart: 20,
+        closeFace: 0,
         options:{
           controls:true,
           autoplay: true, // 如果true,浏览器准备好时开始回放。
@@ -294,6 +302,10 @@
           if (res.code == 200) {
             let {info, extra, list, tpl, extraXs} = res.data;
             this.info =  Object.assign( info, extra||{});
+            this.heartbeat = res.data.heartbeat||5;
+            this.collectBeat = res.data.collectBeat||20;
+            this.maxErrorCount = res.data.maxErrorCount||3;
+            this.closeFace = res.data.info.closeFace;
             this.tpl = tpl||{};
             this.extraXs = extraXs||{};
             this.list = list.map( (item)=>{
@@ -364,6 +376,7 @@
           this.options.playtimes = position
           this.media.id = id;
           this.mediaId = id;
+          this.mediaType ='hls'
           this.options.sources = [{src:this.mediaUrl,type: "application/x-mpegURL"}];
           this.show = 4
         });