|
@@ -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());
|