|
@@ -5,17 +5,13 @@
|
|
<strong>/</strong>
|
|
<strong>/</strong>
|
|
<span>{{media.duration|useTime}}</span>
|
|
<span>{{media.duration|useTime}}</span>
|
|
</h2>
|
|
</h2>
|
|
- <el-row>
|
|
|
|
- <el-col :span="6" style="width: 120px;">
|
|
|
|
- <div class="v-wrap-marks" style="width: 110px;">
|
|
|
|
- <video ref="video" v-show="isnotbtn" width="110" height="110" autoplay></video>
|
|
|
|
- <div class="tc" style="margin-top: 64px; margin-left: 120px;">
|
|
|
|
- <canvas ref="canvas" v-show="isnotbtn" width="240" height="210"></canvas>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <el-row style="width: 900px;">
|
|
|
|
+ <el-col :span="8" style="width: 250px;">
|
|
|
|
+ <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>
|
|
</el-col>
|
|
|
|
|
|
- <el-col :span="18">
|
|
|
|
|
|
+ <el-col :span="16" style="width: 640px;">
|
|
<video-player id="myVideo" class="video-player-box" ref="videoPlayer" :playsinline="true" @pause="onPlayerPause($event)"
|
|
<video-player id="myVideo" class="video-player-box" ref="videoPlayer" :playsinline="true" @pause="onPlayerPause($event)"
|
|
@play="onPlayerStart($event)" @ready="playerReadied" @timeupdate="onPlayerTimeupdate($event)" @ended="onPlayerEnded($event)"
|
|
@play="onPlayerStart($event)" @ready="playerReadied" @timeupdate="onPlayerTimeupdate($event)" @ended="onPlayerEnded($event)"
|
|
:globalOptions="{controls:true}" :options="options">
|
|
:globalOptions="{controls:true}" :options="options">
|
|
@@ -48,6 +44,7 @@
|
|
prevTime: 0,
|
|
prevTime: 0,
|
|
isReady: false,
|
|
isReady: false,
|
|
isnotbtn: false,
|
|
isnotbtn: false,
|
|
|
|
+ ontakebtn: false,
|
|
curTimes: 0,
|
|
curTimes: 0,
|
|
errMsg:'',
|
|
errMsg:'',
|
|
errCount: 0,
|
|
errCount: 0,
|
|
@@ -104,6 +101,9 @@
|
|
return this.$refs.videoPlayer.player
|
|
return this.$refs.videoPlayer.player
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ destroyed(){
|
|
|
|
+ this.closeCamera()
|
|
|
|
+ },
|
|
created() {
|
|
created() {
|
|
this.startTick()
|
|
this.startTick()
|
|
this.startMonitor();
|
|
this.startMonitor();
|
|
@@ -112,9 +112,11 @@
|
|
photograph() {
|
|
photograph() {
|
|
let ctx = this.$refs["canvas"].getContext("2d");
|
|
let ctx = this.$refs["canvas"].getContext("2d");
|
|
// 把当前视频帧内容渲染到canvas上
|
|
// 把当前视频帧内容渲染到canvas上
|
|
- ctx.drawImage(this.$refs["video"], 0, 0, 320, 240);
|
|
|
|
|
|
+ this.ontakebtn = true
|
|
|
|
+ ctx.drawImage(this.$refs["video"], 0, 0, 240, 180);
|
|
// 转base64格式、图片格式转换、图片质量压缩
|
|
// 转base64格式、图片格式转换、图片质量压缩
|
|
- let imgBase64 = this.$refs["canvas"].toDataURL("image/jpeg", 0.7); // 由字节转换为KB 判断大小
|
|
|
|
|
|
+ let imgBase64 = this.$refs["canvas"].toDataURL("image/jpeg", 1); // 由字节转换为KB 判断大小
|
|
|
|
+ this.ontakebtn = false
|
|
let str = imgBase64.replace("data:image/jpeg;base64,", "");
|
|
let str = imgBase64.replace("data:image/jpeg;base64,", "");
|
|
let param ={id:this.media.id, image: str}
|
|
let param ={id:this.media.id, image: str}
|
|
httpServer("course.collect", param).then(res => {
|
|
httpServer("course.collect", param).then(res => {
|
|
@@ -156,10 +158,8 @@
|
|
});
|
|
});
|
|
},
|
|
},
|
|
closeCamera() {
|
|
closeCamera() {
|
|
- if (!this.$refs["video"].srcObject) {
|
|
|
|
- this.dialogCamera = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if( !this.$refs["video"] ) return;
|
|
|
|
+ if (!this.$refs["video"].srcObject) return;
|
|
let stream = this.$refs["video"].srcObject;
|
|
let stream = this.$refs["video"].srcObject;
|
|
let tracks = stream.getTracks();
|
|
let tracks = stream.getTracks();
|
|
tracks.forEach((track) => {
|
|
tracks.forEach((track) => {
|
|
@@ -296,7 +296,7 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 异常 10秒检查
|
|
// 异常 10秒检查
|
|
- if ( this.errCount > 0 && this.tickNum % 20 == 1){
|
|
|
|
|
|
+ if ( this.errCount > 0 && this.tickNum % 20 == 3){
|
|
this.photograph()
|
|
this.photograph()
|
|
}else if ( this.tickNum % 60 == 1){
|
|
}else if ( this.tickNum % 60 == 1){
|
|
this.photograph()
|
|
this.photograph()
|