浏览代码

倒计时

y595705120 5 月之前
父节点
当前提交
ad256de04c
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 11 4
      src/containers/center/play/components/iMedia.vue
  2. 1 0
      src/containers/center/play/components/media.vue

+ 11 - 4
src/containers/center/play/components/iMedia.vue

@@ -1,13 +1,15 @@
 <template>
   <div>
     <h2 class="tc">
+      <span style="float: left;" v-if="nextFaceTick" >
+        <span style="font-size: 10px;">倒计时:{{nextFaceTick}}S</span>
+      </span>
       <span>{{curTimes|useTime}}</span>
       <strong>/</strong>
       <span>{{media.duration|useTime}}</span>
     </h2>
     <el-row style="width: 1100px;">
       <el-col :span="18" style="width:680px;">
-
         <div style="height: 540px;">
         <video-player id="myVideo" class="video-player-box" ref="videoPlayer"
           @pause="onPlayerPause($event)"
@@ -16,7 +18,6 @@
           @timeupdate="onPlayerTimeupdate($event)" @ended="onPlayerEnded($event)" :globalOptions="{controls:true}"
           :options="options">
         </video-player>
-
         </div>
 
         <div class="tc">
@@ -125,6 +126,7 @@
         tickNum: 0,
         prevTime: 0,
         isReady: false,
+        nextFaceTick: 0,
         identifyFaceDialog: false,
         startPlay: false,     // 开始认证
         nextFaceTime: 0,
@@ -236,7 +238,7 @@
         })
       },
       destroyTimer() {
-        if (this.timer) clearInterval(this.timer);
+        if (this.timer) clearTimeout(this.timer);
       },
       goState(item) {
         if (item.name == this.activeChapter) {
@@ -249,12 +251,14 @@
         this.$emit('loadMedia', item, index)
       },
       startTick() {
+        console.log( "startTick")
         let tick = this.tryTick;
         this.destroyTimer();
         this.tickNum = 0;
         this.timer = setTimeout(tick, 1 * 1000);
       },
       stopTick() {
+        console.log( "stopTick")
         if (this.timer) clearInterval(this.timer);
       },
       tryTick() {
@@ -394,8 +398,10 @@
         this.tickNum++
         let now = Date.now()
         // 人脸认证期间 关闭播放
+
         if( !this.closeFace ){
-          //
+            this.nextFaceTick = 0;
+            //
             if( this.identifyFaceDialog  ) {
               // 在播放中,关闭播放
               if( this.onPlay ){
@@ -422,6 +428,7 @@
                 this.startIdentify();
                 return;
               }
+              this.nextFaceTick = parseInt( (this.nextFaceTime-now  )/1000);
             }
         }
         // 未开始

+ 1 - 0
src/containers/center/play/components/media.vue

@@ -14,6 +14,7 @@
           <strong>/</strong>
           <span>{{media.duration|useTime}}</span>
         </el-col>
+
         <el-col :span="4" class="media-center">
           <el-button class="bicon" v-if="!onPlay" type="primary" @click="doPlay" icon="el-icon-video-play" circle></el-button>
           <el-button class="bicon" v-else type="warning" @click="doPause" icon="el-icon-video-pause" circle></el-button>