Selaa lähdekoodia

直播选择视频素材库

yuhongqi 1 kuukausi sitten
vanhempi
commit
2177747c24
3 muutettua tiedostoa jossa 602 lisäystä ja 182 poistoa
  1. 438 0
      src/components/VideoUpload/index.vue
  2. 33 25
      src/views/live/live/index.vue
  3. 131 157
      src/views/live/liveVideo/index.vue

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

@@ -0,0 +1,438 @@
+<template>
+  <div>
+    <el-form-item label="">
+      <div class="upload_video" id="upload_video">
+        <el-upload
+          class="upload-demo"
+          ref="upload"
+          action="#"
+          :http-request="uploadVideoToTxPcdn"
+          accept=".mp4"
+          :limit="1"
+          :on-remove="handleRemove"
+          :on-change="handleChange"
+          :auto-upload="false"
+          :key="uploadKey"
+        >
+          <el-button slot="trigger" size="small" type="primary" >选取视频</el-button>
+          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">点击上传</el-button>
+          <!-- 仅当showControl为true时显示视频库选取按钮 -->
+          <el-button v-if="showControl" style="margin-left: 10px;" size="small" type="success" @click="openVideoLibrary">视频库选取</el-button>
+          <!-- 线路一 -->
+          <div class="progress-container">
+            <span class="progress-label">线路一</span>
+            <el-progress
+              style="margin-top: 5px;"
+              class="progress"
+              :text-inside="true"
+              :stroke-width="18"
+              :percentage="txProgress"
+              status="success">
+            </el-progress>
+          </div>
+
+          <!-- 线路二 -->
+<!--          <div class="progress-container">-->
+<!--            <span class="progress-label">线路二</span>-->
+<!--            <el-progress-->
+<!--              style="margin-top: 5px;"-->
+<!--              class="progress"-->
+<!--              :text-inside="true"-->
+<!--              :stroke-width="18"-->
+<!--              :percentage="hwProgress"-->
+<!--              status="success">-->
+<!--            </el-progress>-->
+<!--          </div>-->
+          <div slot="tip" class="el-upload__tip">只能上传mp4文件,且不超过500M</div>
+        </el-upload>
+      </div>
+    </el-form-item>
+    <el-form-item label="视频播放">
+      <video v-if="videoUrl" ref="myvideo" :src="videoUrl" id="video" width="100%" height="300px" controls></video>
+      <div v-if="fileName">视频文件名: {{ fileName }}</div>
+      <div v-if="fileKey">文件Key: {{ fileKey }}</div>
+      <div v-if="fileSize">文件大小(MB): {{ (fileSize / (1024 * 1024)).toFixed(2) }} MB</div>
+    </el-form-item>
+    <!-- 仅当showControl为true时显示播放线路选择器 -->
+<!--    <el-form-item v-if="showControl" label="播放线路">-->
+<!--      <el-radio-group v-model="localUploadType">-->
+<!--        <el-radio :label="1" >线路一</el-radio>-->
+<!--&lt;!&ndash;        <el-radio :label="2" >线路二</el-radio>&ndash;&gt;-->
+<!--        &lt;!&ndash;        <el-radio :label="3" >线路三</el-radio>&ndash;&gt;-->
+<!--      </el-radio-group>-->
+<!--    </el-form-item>-->
+
+    <!-- 视频库选择对话框 -->
+    <el-dialog title="视频库选择" :visible.sync="libraryOpen" width="900px" append-to-body>
+      <!-- 搜索条件 -->
+      <el-form :inline="true" :model="libraryQueryParams" class="library-search">
+        <el-form-item label="素材名称">
+          <el-input
+            v-model="libraryQueryParams.remark"
+            placeholder="请输入素材名称"
+            clearable
+            size="small"
+            @keyup.enter.native="handleLibraryQuery"
+          />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleLibraryQuery">搜索</el-button>
+          <el-button icon="el-icon-refresh" size="mini" @click="resetLibraryQuery">重置</el-button>
+        </el-form-item>
+      </el-form>
+
+      <!-- 视频列表 -->
+      <el-table v-loading="libraryLoading" :data="libraryList" @row-click="handleLibrarySelect" highlight-current-row>
+        <el-table-column label="素材名称" align="center" prop="remark" />
+        <el-table-column label="缩略图" align="center">
+          <template slot-scope="scope">
+            <video
+              :src="scope.row.videoUrl"
+              controls
+              controlsList="nodownload"
+              class="video-player"
+              @contextmenu.prevent
+            ></video>
+          </template>
+        </el-table-column>
+        <el-table-column label="视频时长" align="center">
+          <template slot-scope="scope">
+            <span>{{ formatDuration(scope.row.duration) }}</span>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <!-- 分页 -->
+      <pagination
+        v-show="libraryTotal>0"
+        :total="libraryTotal"
+        :page.sync="libraryQueryParams.pageNum"
+        :limit.sync="libraryQueryParams.pageSize"
+        @pagination="getLibraryList"
+      />
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="confirmVideoSelection">确 定</el-button>
+        <el-button @click="cancelVideoSelection">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { uploadObject } from "@/utils/cos.js";
+import Pagination from "@/components/Pagination";
+// import { listVideoResource } from '@/api/course/videoResource';
+import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo } from "@/api/live/liveVideo";
+
+export default {
+  components: {
+    Pagination
+  },
+  props: {
+    videoUrl: {
+      type: String,
+      default: "",
+    },
+    fileKey: {
+      type: String,
+      default: "",
+    },
+    fileSize: {
+      type: Number,
+      default: null,
+    },
+    fileName: {
+      type: String,
+      default: "",
+    },
+    line_1: {
+      type: String,
+      default: "",
+    },
+    line_2: {
+      type: String,
+      default: "",
+    },
+    line_3: {
+      type: String,
+      default: "",
+    },
+    thumbnail: {
+      type: String,
+      default: "",
+    },
+    uploadType: {
+      type: Number,
+      default: null,
+    },
+    type: {
+      type: Number,
+      default: null,
+    },
+    isPrivate: {
+      type: Number,
+      default: 0,
+    },
+
+    // 使用一个变量控制显示,默认为true显示所有控制项
+    showControl: {
+      type: Boolean,
+      default: true,
+    }
+  },
+  data() {
+    return {
+      videoName:'',
+      isHidden : false,
+      localUploadType: this.uploadType,
+      duration: 0,
+      fileId: "",
+      uploadTypeOptions: [
+        { dictLabel: "线路一", dictValue: 1 }, // 腾讯pcdn
+        { dictLabel: "线路二", dictValue: 2 }, // 华为云obs
+        // { dictLabel: "华为云VOD", dictValue: 4 },
+        // { dictLabel: "腾讯云VOD", dictValue: 5 },
+      ],
+      fileList: [],
+      txProgress: 0,
+      hwProgress: 0,
+      uploadLoading: false,
+      uploadKey: 0,
+      // 视频库选择相关数据
+      libraryOpen: false,
+      libraryLoading: false,
+      libraryTotal: 0,
+      libraryList: [],
+      selectedVideo: null,
+      libraryQueryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        resourceName: null,
+        liveId: -1,
+        videoUrl: null,
+        videoType: -1,
+        sort: null,
+        remark: null,
+      },
+      liveQueryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        liveId: -1,
+        videoUrl: null,
+        videoType: -1,
+        sort: null,
+        remark: null,
+      },
+    };
+  },
+  watch: {
+    localUploadType(newType) {
+      this.$emit("update:uploadType", newType);
+      this.$emit("change");
+    },
+    uploadType(newType) {
+      this.localUploadType = newType;
+    },
+  },
+  methods: {
+    /** 查询直播视频列表 */
+    getList() {
+      this.libraryLoading = true;
+      listLiveVideo(this.libraryQueryParams).then(response => {
+        this.libraryList = response.rows;
+        this.libraryTotal = response.total;
+        this.libraryLoading = false;
+      });
+    },
+    // 打开视频库对话框
+    openVideoLibrary() {
+      this.libraryOpen = true;
+      this.selectedVideo = null;
+      this.getList();
+    },
+    handleChange(file, fileList) {
+      this.fileList = fileList;
+      this.getVideoDuration(file.raw);
+    },
+    getVideoDuration(file) {
+      const video = document.createElement("video");
+      video.preload = "metadata";
+      video.onloadedmetadata = () => {
+        window.URL.revokeObjectURL(video.src);
+        this.duration = parseInt(video.duration.toFixed(2));
+        console.log("视频时长=========>",this.duration);
+        this.$emit("video-duration", this.duration);
+        console.log("文件大小=====>",file.size);
+        this.$emit("update:fileSize", file.size);
+      };
+      video.src = URL.createObjectURL(file);
+    },
+    async submitUpload() {
+      if (this.fileList.length < 1) {
+        return this.$message.error("请先选取视频,再进行上传");
+      }
+      //同时上传个线路
+      await this.uploadVideoToTxPcdn();
+      this.$emit("update:fileName", this.fileList[0].name);
+    },
+    //获取第一帧封面
+    async getFirstThumbnail(){
+      const file = this.fileList[0].raw;
+      getThumbnail(file).then(response => {
+        console.log("获取到第一帧为封面======>",response.url)
+        this.$emit("update:thumbnail", response.url);
+      })
+    },
+    //更新华为线路进度条
+    // updateHwProgress(progress) {
+    //   this.hwProgress = progress;
+    // },
+    //更新腾讯线路进度条
+    updateTxProgress(progressData) {
+      this.txProgress = Math.round(progressData.percent * 100);
+    },
+    //上传腾讯云Pcdn
+    async uploadVideoToTxPcdn() {
+      try {
+        const file = this.fileList[0].raw;
+        const data = await uploadObject(file, this.updateTxProgress,this.type);
+        console.log("腾讯COS返回========>",data);
+        console.log("isPrivate=======>",this.isPrivate)
+        let line_1='' ;
+        if (this.isPrivate===0){
+          line_1 = `${process.env.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+        }else {
+          line_1 = `${process.env.VUE_APP_VIDEO_LINE_1}${data.urlPath}`;
+        }
+
+        let urlPathWithoutFirstSlash = data.urlPath.substring(1);
+        this.$emit("update:fileKey", urlPathWithoutFirstSlash);
+
+        console.log("文件key",urlPathWithoutFirstSlash);
+        console.log("组装URL========>",line_1);
+        this.$emit("update:videoUrl", line_1);
+        this.$emit("update:line_1", line_1);
+        // this.$emit("update:line_2", line_2);
+        this.$message.success("线路一上传成功");
+      } catch (error) {
+        this.$message.error("线路一上传失败");
+      }
+    },
+    //上传华为云Obs
+    async uploadVideoToHwObs() {
+      try {
+        const file = this.fileList[0].raw;
+        const data = await uploadToOBS(file, this.updateHwProgress,this.type);
+        console.log("华为OBS返回========>",data);
+        let line_2='' ;
+        if (this.isPrivate===0){
+          line_2 = `${process.env.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+        }else {
+          line_2 = `${process.env.VUE_APP_VIDEO_LINE_2}/${data.urlPath}`;
+        }
+        // this.$emit("update:videoUrl", data);
+        this.$emit("update:line_2", line_2);
+        this.$message.success("线路二上传成功");
+      } catch (error) {
+        this.$message.error("线路二上传失败");
+      }
+    },
+    handleRemove(file, fileList) {
+      console.log(file, fileList.length);
+    },
+    resetUpload() {
+      // 重置内部状态
+      this.txProgress = 0;
+      this.hwProgress = 0;
+      this.fileList = [];
+      this.uploadKey++;
+    },
+    /** 查询视频库列表 */
+    getLibraryList() {
+      this.libraryLoading = true;
+      // listVideoResource(this.libraryQueryParams).then(response => {
+      //   this.libraryList = response.rows;
+      //   this.libraryTotal = response.total;
+      //   this.libraryLoading = false;
+      // });
+    },
+    /** 搜索视频库按钮操作 */
+    handleLibraryQuery() {
+      this.libraryQueryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置视频库查询按钮操作 */
+    resetLibraryQuery() {
+      this.libraryQueryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        resourceName: null
+      };
+      this.handleLibraryQuery();
+    },
+    /** 视频库选择行点击 */
+    handleLibrarySelect(row) {
+      this.selectedVideo = row;
+    },
+    /** 格式化视频时长 */
+    formatDuration(seconds) {
+      if (!seconds) return '00:00';
+
+      const minutes = Math.floor(seconds / 60);
+      const remainingSeconds = seconds % 60;
+
+      return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
+    },
+    /** 确认选择视频 */
+    confirmVideoSelection() {
+      if (!this.selectedVideo) {
+        this.$message.warning("请选择一个视频");
+        return;
+      }
+
+      // 更新组件内部数据
+      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);
+      this.$emit("change", this.selectedVideo.videoUrl,this.selectedVideo.lineOne);
+
+
+      this.libraryOpen = false;
+    },
+    /** 取消视频选择 */
+    cancelVideoSelection() {
+      this.libraryOpen = false;
+      this.selectedVideo = null;
+    }
+  }
+};
+</script>
+
+<style>
+.progress-container {
+  margin-bottom: 5px; /* 进度条之间的间距 */
+}
+
+.progress-label {
+  display: block;
+  font-weight: bold;
+  font-size: 13px;
+  color: #303331; /* 标签颜色,可以根据需要调整 */
+}
+
+/* 视频库选择对话框样式 */
+.library-search {
+  margin-bottom: 15px;
+}
+
+.el-table .el-table__row:hover {
+  cursor: pointer;
+}
+</style>

+ 33 - 25
src/views/live/live/index.vue

@@ -246,25 +246,32 @@
           <Editor ref="myeditor" :height="300" @on-text-change="updateText"/>
           <!--          <Editor v-model="form.liveDesc" :height="300" placeholder="直播描述" />-->
         </el-form-item>
-        <video-upload
-          v-if="form.liveType == 2"
-          :type = "1"
-          :isPrivate = "isPrivate"
-          :fileKey.sync = "form.fileKey"
-          :fileSize.sync = "form.fileSize"
-          :videoUrl.sync="videoUrl"
-          :fileName.sync="form.fileName"
-          :line_2.sync="form.lineTwo"
-          :line_1.sync="form.lineOne"
-          :thumbnail.sync="form.thumbnail"
-          :uploadType.sync="form.uploadType"
-          :isTranscode.sync="form.isTranscode"
-          :transcodeFileKey.sync="form.transcodeFileKey"
-          @video-duration="handleVideoDuration"
-          @change="handleVideoChange"
-          ref="videoUpload"
-          append-to-body
-        />
+        <el-form-item label="录播视屏" prop="videoUrl" v-if="form.liveType == 2">
+          <video-upload :fileKey.sync="form.fileKey" :fileSize.sync="form.fileSize"
+                        :videoUrl.sync="form.videoUrl" :fileName.sync="form.fileName" :line_1.sync="form.lineOne"
+                        :uploadType.sync="form.uploadType" :isTranscode.sync="form.isTranscode"
+                        :transcodeFileKey.sync="form.transcodeFileKey" @video-duration="handleVideoDuration"
+                        @change="handleVideoChange"></video-upload>
+        </el-form-item>
+<!--        <video-upload-->
+<!--          v-if="form.liveType == 2"-->
+<!--          :type = "1"-->
+<!--          :isPrivate = "isPrivate"-->
+<!--          :fileKey.sync = "form.fileKey"-->
+<!--          :fileSize.sync = "form.fileSize"-->
+<!--          :videoUrl.sync="videoUrl"-->
+<!--          :fileName.sync="form.fileName"-->
+<!--          :line_2.sync="form.lineTwo"-->
+<!--          :line_1.sync="form.lineOne"-->
+<!--          :thumbnail.sync="form.thumbnail"-->
+<!--          :uploadType.sync="form.uploadType"-->
+<!--          :isTranscode.sync="form.isTranscode"-->
+<!--          :transcodeFileKey.sync="form.transcodeFileKey"-->
+<!--          @video-duration="handleVideoDuration"-->
+<!--          @change="handleVideoChange"-->
+<!--          ref="videoUpload"-->
+<!--          append-to-body-->
+<!--        />-->
         <el-form-item label="开始时间" prop="startTime">
           <el-date-picker size="small"
                           v-model="form.startTime"
@@ -341,7 +348,7 @@ import {
 } from "@/api/live/live";
 import Editor from '@/components/Editor/wang';
 import user from '@/store/modules/user';
-import VideoUpload from "@/components/LiveVideoUpload/index.vue";
+import VideoUpload from "@/components/VideoUpload/index.vue";
 
 export default {
   name: "Live",
@@ -397,7 +404,12 @@ export default {
       form: {
         uploadType: 1,
         isTranscode:0,
-        transcodeFileKey:null
+        transcodeFileKey:null,
+        videoUrl: null,
+        fileKey: null,
+        fileName: null,
+        fileSize: null,
+        lineOne: null,
       },
       // 表单校验
       rules: {
@@ -410,9 +422,6 @@ export default {
         liveType: [
           { required: true, message: "不能为空", trigger: "burl" }
         ],
-        videoUrl: [
-          { required: true, message: "不能为空", trigger: "burl" }
-        ],
         startTime: [
           { required: true, message: "不能为空", trigger: "burl" }
         ],
@@ -557,7 +566,6 @@ export default {
     handleVideoChange(videoUrl,lineOne){
       this.videoUrl = videoUrl;
       this.form.videoUrl = videoUrl;
-      console.log(this.videoUrl)
     },
     changeDuration(e){
       this.form.duration = e.duration;

+ 131 - 157
src/views/live/liveVideo/index.vue

@@ -1,117 +1,47 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="直播ID" prop="liveId">
-        <el-input
-          v-model="queryParams.liveId"
-          placeholder="请输入直播ID"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="视频地址" prop="videoUrl">
-        <el-input
-          v-model="queryParams.videoUrl"
-          placeholder="请输入视频地址"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="类型 1录播 2回放" prop="videoType">
-        <el-select v-model="queryParams.videoType" placeholder="请选择类型 1录播 2回放" clearable size="small">
-          <el-option label="请选择字典生成" value="" />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="排序号" prop="sort">
-        <el-input
-          v-model="queryParams.sort"
-          placeholder="请输入排序号"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
-      </el-form-item>
-    </el-form>
 
-    <el-row :gutter="10" class="mb8">
-      <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['live:liveVideo:add']"
-        >新增</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="success"
-          plain
-          icon="el-icon-edit"
-          size="mini"
-          :disabled="single"
-          @click="handleUpdate"
-          v-hasPermi="['live:liveVideo:edit']"
-        >修改</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="el-icon-delete"
-          size="mini"
-          :disabled="multiple"
-          @click="handleDelete"
-          v-hasPermi="['live:liveVideo:remove']"
-        >删除</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="warning"
-          plain
-          icon="el-icon-download"
-          size="mini"
-          :loading="exportLoading"
-          @click="handleExport"
-          v-hasPermi="['live:liveVideo:export']"
-        >导出</el-button>
-      </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
-    </el-row>
+<!--    <el-row :gutter="10" class="mb8">-->
+<!--      <el-col :span="1.5">-->
+<!--        <el-button-->
+<!--          type="primary"-->
+<!--          plain-->
+<!--          icon="el-icon-plus"-->
+<!--          size="mini"-->
+<!--          @click="handleAdd"-->
+<!--          v-hasPermi="['live:liveVideo:add']"-->
+<!--        >新增</el-button>-->
+<!--      </el-col>-->
+<!--      <el-col :span="1.5">-->
+<!--        <el-button-->
+<!--          type="danger"-->
+<!--          plain-->
+<!--          icon="el-icon-delete"-->
+<!--          size="mini"-->
+<!--          :disabled="multiple"-->
+<!--          @click="handleDelete"-->
+<!--          v-hasPermi="['live:liveVideo:remove']"-->
+<!--        >删除</el-button>-->
+<!--      </el-col>-->
+<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
+<!--    </el-row>-->
 
     <el-table border v-loading="loading" :data="liveVideoList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="ID" align="center" prop="videoId" />
-      <el-table-column label="直播ID" align="center" prop="liveId" />
-      <el-table-column label="视频地址" align="center" prop="videoUrl" />
-      <el-table-column label="类型 1录播 2回放" align="center" prop="videoType" />
-      <el-table-column label="排序号" align="center" prop="sort" />
-      <el-table-column label="备注" align="center" prop="remark" />
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="编号" align="center" prop="videoId" />
+      <el-table-column label="视频名称" align="center" prop="remark" />
+      <el-table-column label="视频地址" align="center" prop="videoUrl">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            v-hasPermi="['live:liveVideo:edit']"
-          >修改</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['live:liveVideo:remove']"
-          >删除</el-button>
+          <video
+            :src="scope.row.videoUrl"
+            controls
+            controlsList="nodownload"
+            class="video-player"
+            @contextmenu.prevent
+          ></video>
         </template>
       </el-table-column>
+      <el-table-column label="时长" align="center" prop="duration" :formatter="formatDuration"/>
     </el-table>
 
     <pagination
@@ -125,23 +55,24 @@
     <!-- 添加或修改直播视频对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="直播ID" prop="liveId">
-          <el-input v-model="form.liveId" placeholder="请输入直播ID" />
-        </el-form-item>
-        <el-form-item label="视频地址" prop="videoUrl">
-          <el-input v-model="form.videoUrl" placeholder="请输入视频地址" />
-        </el-form-item>
-        <el-form-item label="类型 1录播 2回放" prop="videoType">
-          <el-select v-model="form.videoType" placeholder="请选择类型 1录播 2回放">
-            <el-option label="请选择字典生成" value="" />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="排序号" prop="sort">
-          <el-input v-model="form.sort" placeholder="请输入排序号" />
-        </el-form-item>
-        <el-form-item label="备注" prop="remark">
-          <el-input v-model="form.remark" placeholder="请输入备注" />
-        </el-form-item>
+        <live-video-upload
+          :type = "1"
+          :isPrivate = "isPrivate"
+          :fileKey.sync = "form.fileKey"
+          :fileSize.sync = "form.fileSize"
+          :videoUrl.sync="form.videoUrl"
+          :fileName.sync="form.fileName"
+          :line_1.sync="form.lineOne"
+          :thumbnail.sync="form.thumbnail"
+          :uploadType.sync="form.uploadType"
+          :isTranscode.sync="form.isTranscode"
+          :transcodeFileKey.sync="form.transcodeFileKey"
+          @video-duration="handleVideoDuration"
+          @change="handleVideoChange"
+          ref="videoUpload"
+          append-to-body
+        />
+
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -153,11 +84,15 @@
 
 <script>
 import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo } from "@/api/live/liveVideo";
+import LiveVideoUpload from "@/components/LiveVideoUpload/index.vue";
 
 export default {
   name: "LiveVideo",
+  components: { LiveVideoUpload },
   data() {
     return {
+      //字典
+      videoTypeOptions: [],
       // 遮罩层
       loading: true,
       // 导出遮罩层
@@ -182,22 +117,49 @@ export default {
       queryParams: {
         pageNum: 1,
         pageSize: 10,
-        liveId: null,
+        liveId: -1,
         videoUrl: null,
-        videoType: null,
+        videoType: -1,
         sort: null,
       },
       // 表单参数
-      form: {},
+      form: {
+        uploadType: 1,
+        isTranscode:0,
+        transcodeFileKey:null
+      },
       // 表单校验
       rules: {
-      }
+      },
+      isPrivate:null,
     };
   },
   created() {
     this.getList();
   },
   methods: {
+    handleVideoDuration(duration) {
+      this.form.duration = duration;
+    },
+    handleVideoChange(videoUrl,lineOne){
+      this.videoUrl = videoUrl;
+      this.form.videoUrl = videoUrl;
+      console.log(this.videoUrl)
+    },
+    // 操作日志类型字典翻译
+    formatDuration(row, column) {
+      if(row.duration == null) return "00:00"
+      const h = Math.floor(row.duration / 3600);
+      const m = Math.floor((row.duration % 3600) / 60);
+      const s = Math.floor(row.duration % 60);
+
+      // 补零处理
+      const format = (num) => num.toString().padStart(2, '0');
+
+      return h > 0
+        ? `${h}:${format(m)}:${format(s)}`
+        : `${format(m)}:${format(s)}`;
+    },
     /** 查询直播视频列表 */
     getList() {
       this.loading = true;
@@ -207,6 +169,9 @@ export default {
         this.loading = false;
       });
     },
+    videoTypeFormatter(row, column) {
+      return this.selectDictLabel(this.videoTypeOptions, row.status);
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -264,19 +229,20 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          if (this.form.videoId != null) {
-            updateLiveVideo(this.form).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            addLiveVideo(this.form).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
+          this.form.videoType = -1;
+          this.form.liveId = -1;
+          this.form.remark = this.form.fileName;
+          if(this.form.videoUrl == null || this.form.videoUrl == "") {
+            this.msgError("请上传视频");
+            return;
           }
+          addLiveVideo(this.form).then(response => {
+            this.msgSuccess("新增成功");
+            this.open = false;
+            this.getList();
+            this.reset();
+          });
+
         }
       });
     },
@@ -284,31 +250,39 @@ export default {
     handleDelete(row) {
       const videoIds = row.videoId || this.ids;
       this.$confirm('是否确认删除直播视频编号为"' + videoIds + '"的数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delLiveVideo(videoIds);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        }).catch(() => {});
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function() {
+        return delLiveVideo(videoIds);
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("删除成功");
+      }).catch(() => {});
     },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
       this.$confirm('是否确认导出所有直播视频数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
-          this.exportLoading = true;
-          return exportLiveVideo(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-          this.exportLoading = false;
-        }).catch(() => {});
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.exportLoading = true;
+        return exportLiveVideo(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+        this.exportLoading = false;
+      }).catch(() => {});
     }
   }
 };
 </script>
+
+<style scoped>
+.video-player {
+  width: 100%;
+  height: 100%;
+  object-fit: cover;
+}
+</style>