From 24387955fed14e5a7c425ca36a12a0440fa55f3e Mon Sep 17 00:00:00 2001
From: duhang <447647896@qq.com>
Date: Wed, 10 Jan 2024 10:42:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=BE=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/ali-player/index.vue | 18 +++++-
src/components/video/index.vue | 1 +
src/request/api.js | 6 ++
.../courseware/video.vue | 55 +++++++++++++++++--
4 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/src/components/ali-player/index.vue b/src/components/ali-player/index.vue
index 45dc1ad..99d93ae 100644
--- a/src/components/ali-player/index.vue
+++ b/src/components/ali-player/index.vue
@@ -67,9 +67,21 @@ const fnCreateAliPlayer = async () => {
player = new window.Aliplayer(
{
id: "J_prismPlayer",
- source: props.source,
- vid: props.vid,
- playauth: props.playAuth,
+ ...(props.source
+ ? { source: props.source }
+ : {
+ vid: props.vid,
+ playauth: props.playAuth,
+ qualitySort: "asc",
+ format: "m3u8",
+ encryptType: 1,
+ mediaType: "video",
+ autoplay: true,
+ isLive: false,
+ rePlay: false,
+ playsinline: true,
+ controlBarVisibility: "hover",
+ }),
cover: props.cover,
width: props.width,
height: props.height,
diff --git a/src/components/video/index.vue b/src/components/video/index.vue
index 19561ed..7dc2008 100644
--- a/src/components/video/index.vue
+++ b/src/components/video/index.vue
@@ -41,6 +41,7 @@ const emits = defineEmits(["update:visible"]);
const visible = useVModel(props, "visible", emits);
const playerRef = ref(null);
const fnSrc = (src) => {
+ if (!src) return;
if (src.indexOf("http") !== -1 || src.indexOf("https") !== -1) return src;
else return VITE_FILE_URL + src;
};
diff --git a/src/request/api.js b/src/request/api.js
index 8fa3a2c..2b95b4c 100644
--- a/src/request/api.js
+++ b/src/request/api.js
@@ -17,3 +17,9 @@ export const getInfo = (params) =>
export const setUploadImg = (params) => upload("/imgfiles/add", params); // 上传附件
export const setDeleteImg = (params) => post("/imgfiles/delete", params); // 删除附件
export const getViewImg = (params) => post("/imgfiles/listImgs", params); // 查看图片
+
+export const getVideoSource = (params) =>
+ post("/videoRes/getVideoPlayAuth", params); // 获取视频 目前404
+
+export const getVideoAuth = (params) =>
+ post("/videocourseware/getVideoPlayAuth", params); // 获取视频权限
diff --git a/src/views/platform_resource_library/courseware/video.vue b/src/views/platform_resource_library/courseware/video.vue
index c65d151..3c43eba 100644
--- a/src/views/platform_resource_library/courseware/video.vue
+++ b/src/views/platform_resource_library/courseware/video.vue
@@ -104,7 +104,17 @@
-
+
预览
+
@@ -153,6 +169,8 @@ import LayoutTable from "@/components/table/index.vue";
import { debounce } from "throttle-debounce";
import { ElMessage, ElMessageBox } from "element-plus";
import { useRouter } from "vue-router";
+import LayoutVideo from "@/components/video/index.vue";
+import { getVideoAuth, getVideoSource } from "@/request/api.js";
const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
@@ -163,8 +181,12 @@ const data = reactive({
{ value: "0", label: "启用" },
{ value: "1", label: "禁用" },
],
- videoVisible: false,
- videoSource: "",
+ videoDialog: {
+ src: "",
+ vid: "",
+ playAuth: "",
+ visible: false,
+ },
});
const fnAdd = debounce(1000, async (VIDEOCOURSEWARE_ID) => {
@@ -174,9 +196,30 @@ const fnAdd = debounce(1000, async (VIDEOCOURSEWARE_ID) => {
fnResetPagination();
});
-const fnOpenVideo = async () => {
- // todo
- ElMessage.info("功能开发中");
+const fnPreviewVideo = async (row) => {
+ if (
+ row.VIDEOCOURSEWARE_ID_REMOTE &&
+ row.VIDEOCOURSEWARE_ID_REMOTE.length > 0
+ ) {
+ const respData = await getVideoSource({
+ VIDEOCOURSEWARE_ID: row.VIDEOCOURSEWARE_ID_REMOTE,
+ CURRICULUM_ID: row.CURRICULUM_ID_REMOTE,
+ });
+ if (respData && respData.result === "success") {
+ data.videoDialog.playAuth = respData.playAuth;
+ data.videoDialog.vid = row.VIDEOFILES;
+ data.videoDialog.visible = true;
+ }
+ } else if (row.VIDEOFILES && row.VIDEOFILES.length > 0) {
+ const respData = await getVideoAuth({
+ videoId: row.VIDEOFILES,
+ });
+ if (respData && respData.result === "success") {
+ data.videoDialog.playAuth = respData.playAuth;
+ data.videoDialog.vid = row.VIDEOFILES;
+ data.videoDialog.visible = true;
+ }
+ }
};