|
@@ -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");
|
|
|
});
|
|
|
}
|