wws 2 年之前
父节点
当前提交
429b8109c1
共有 3 个文件被更改,包括 109 次插入 和 0 次删除
  1. 72 0
      src/components/small-video/SmallVideo.vue
  2. 6 0
      src/router/index.js
  3. 31 0
      src/views/test-small/TestSmall.vue

+ 72 - 0
src/components/small-video/SmallVideo.vue

@@ -0,0 +1,72 @@
+<script>
+import Player from "@/utils/Player";
+
+export default {
+  name: "SmallVideo",
+  data() {
+    return {
+      playerInstance: null,
+      width: 0,
+      height: 0
+    }
+  },
+  async mounted() {
+    this.playerInstance = new Player();
+    this.$nextTick( async() => {
+      await this.playerInstance.loadPlayerScript();
+      this.playerInstance.loadPlayer();
+      setTimeout(() => {
+        this.playerInstance.play();
+      }, 1000)
+    })
+
+    const smallVideo = document.querySelector(".small-video");
+    this.width = smallVideo.clientWidth;
+    this.height = smallVideo.clientHeight;
+    console.log("playerInstance", this.playerInstance)
+  }
+}
+</script>
+
+<template>
+  <div class="small-video">
+    <div class="video-container"
+         :style="{'--width': width + 'px', '--height': height + 'px'}"
+         :id="playerInstance?.playerId"></div>
+
+    <div class="mask-box">
+
+    </div>
+
+  </div>
+</template>
+
+<style scoped>
+
+.small-video {
+  width: 100%;
+  height: 100%;
+  position: relative;
+}
+
+.video-container {
+  width: 100%;
+  height: 100%;
+  //background: pink;
+}
+
+/deep/ .plv-player-container {
+  width: var(--width);
+  height: var(--height);
+}
+
+.mask-box {
+  position: absolute;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  background: transparent;
+}
+
+</style>

+ 6 - 0
src/router/index.js

@@ -26,6 +26,12 @@ const routes = [
     // path: '/',
     component: () => import( '../views/feed/FeedList.vue')
   },
+  {
+    path: '/test-small',
+    // path: '/',
+    name: "测试小窗",
+    component: () => import( '../views/test-small/TestSmall.vue')
+  },
 ]
 
 const router = new VueRouter({

+ 31 - 0
src/views/test-small/TestSmall.vue

@@ -0,0 +1,31 @@
+<script>
+import SmallVideo from "@/components/small-video/SmallVideo.vue";
+
+export default {
+  name: "TestSmall",
+  components: {SmallVideo}
+}
+</script>
+
+<template>
+  <div class="test-wrapper">
+
+    <div class="test">
+      <small-video />
+    </div>
+
+  </div>
+</template>
+
+<style scoped>
+
+.test-wrapper {
+
+}
+
+.test {
+  width: 100vw;
+  height: 200px;
+}
+
+</style>