Browse Source

更新播放

lex 2 years ago
parent
commit
b988ff401c
2 changed files with 20 additions and 2 deletions
  1. 1 1
      package.json
  2. 19 1
      src/components/video-tcplayer/index.vue

+ 1 - 1
package.json

@@ -21,6 +21,7 @@
     "@rongcloud/imlib-next": "^5.4.3",
     "@shopify/draggable": "^1.0.0-beta.8",
     "@vant/touch-emulator": "^1.4.0",
+    "JSONPath": "^0.11.2",
     "axios": "0.18.1",
     "browserslist": "^4.18.1",
     "caniuse-lite": "^1.0.30001286",
@@ -35,7 +36,6 @@
     "i": "^0.3.6",
     "js-base64": "^3.6.0",
     "js-cookie": "2.2.0",
-    "JSONPath": "^0.11.2",
     "linq": "^3.2.2",
     "lodash": "^4.17.20",
     "mammoth": "^1.4.19",

+ 19 - 1
src/components/video-tcplayer/index.vue

@@ -48,7 +48,8 @@ export default {
   data() {
     return {
       videoID: "video" + Date.now() + Math.floor(Math.random() * 100),
-      player: null
+      player: null,
+      playerPause: true // 是否暂停
     };
   },
   mounted() {
@@ -85,6 +86,14 @@ export default {
 
         this.player.on("play", () => {
           this.$emit("play");
+
+          document.querySelector(".vjs-play-control").onclick = () => {
+            if (this.playerPause) {
+              this.player.play();
+            } else {
+              this.player.pause();
+            }
+          };
         });
 
         // 初步加载时
@@ -96,8 +105,17 @@ export default {
         // this.player.on('timeupdate', () => {
         // });
 
+        this.player.on("playing", () => {
+          this.playerPause = false;
+        });
+
+        this.player.on("pause", () => {
+          this.playerPause = true;
+        });
+
         // 视频播放结束
         this.player.on("ended", () => {
+          this.playerPause = false;
           this.$emit("ended");
         });
       }