Kaynağa Gözat

直播控制台格式解析,新增直播间选择问题

yuhongqi 1 hafta önce
ebeveyn
işleme
24f7c40a4a

+ 0 - 6
src/components/VideoUpload/index.vue

@@ -230,10 +230,6 @@ export default {
     this.reset();
   },
   watch: {
-    localUploadType(newType) {
-      this.$emit("update:uploadType", newType);
-      this.$emit("change");
-    },
     uploadType(newType) {
       this.localUploadType = newType;
     },
@@ -400,11 +396,9 @@ export default {
 
       // 更新组件内部数据
       this.$emit("update:fileName", this.selectedVideo.fileName);
-      this.$emit("update:thumbnail", this.selectedVideo.thumbnail);
       this.$emit("update:line_1", this.selectedVideo.lineOne);
       this.$emit("update:fileSize", this.selectedVideo.fileSize);
       this.$emit("update:fileKey", this.selectedVideo.fileKey);
-      this.$emit("update:uploadType", this.selectedVideo.uploadType);
       this.$emit("video-duration", this.selectedVideo.duration);
       // 设置预览URL
       this.$emit("update:videoUrl", this.selectedVideo.videoUrl);

+ 3 - 3
src/views/live/liveConfig/task.vue

@@ -555,9 +555,9 @@ export default {
       }
       this.loading = true;
       listTask(this.queryParams).then(res => {
-        if(res.rows.length > 0) {
-          this.taskList = res.rows;
-        }
+
+        this.taskList = res.rows;
+
         this.total = res.total;
         this.loading = false;
       });

+ 13 - 6
src/views/live/liveConsole/index.vue

@@ -100,7 +100,7 @@
             class="custom-video"
             style="display: block; background: #000; height: 40vh;"
           >
-            <source :src="videoUrl" type="video/mp4">
+            <source :src="videoUrl" type="application/x-mpegURL">
           </video>
           <!-- 自定义进度条容器 -->
           <div ref="progressBar" class="progress-container">
@@ -122,7 +122,7 @@
             playsinline
             style="display: block; background: #000; height: 40vh;"
           >
-            <source :src="videoUrl" type="video/mp4">
+            <source :src="videoUrl" type="application/x-mpegURL">
           </video>
         </div>
         <div style="border-radius: 5px; overflow: hidden;" v-else>
@@ -393,7 +393,6 @@ export default {
     this.$nextTick(() => {
       const video = this.$refs.videoPlayer;
       if (video != null) {
-        video.play();
         this.initVideoPlayer(this.liveInfo.startTime)
       }
     })
@@ -453,7 +452,17 @@ export default {
     },
     initVideoPlayer: function (startTime) {
       const video = this.$refs.videoPlayer;
-
+      this.hls = new Hls();
+      this.hls.attachMedia(video);
+      this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
+        this.hls.loadSource(this.videoUrl);
+        this.hls.on(Hls.Events.STREAM_LOADED, (event, data) => {
+          video.play();
+        });
+      });
+      this.hls.on(Hls.Events.ERROR, (event, data) => {
+        console.error('HLS 错误:', data);
+      });
 
       // 1. 初始化开播时间
       startTime = new Date(startTime).getTime();
@@ -588,8 +597,6 @@ export default {
               this.liveType = 2
               this.videoUrl = res.data.videoUrl;
               this.$nextTick(() => {
-                const video = this.$refs.videoPlayer;
-                video.play()
                 this.initVideoPlayer(res.data.startTime)
               })
             }