视频课件

pull/1/head
duhang 2024-01-10 10:42:12 +08:00
parent 43298dfa07
commit 24387955fe
4 changed files with 71 additions and 9 deletions

View File

@ -67,9 +67,21 @@ const fnCreateAliPlayer = async () => {
player = new window.Aliplayer( player = new window.Aliplayer(
{ {
id: "J_prismPlayer", id: "J_prismPlayer",
source: props.source, ...(props.source
vid: props.vid, ? { source: props.source }
playauth: props.playAuth, : {
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, cover: props.cover,
width: props.width, width: props.width,
height: props.height, height: props.height,

View File

@ -41,6 +41,7 @@ const emits = defineEmits(["update:visible"]);
const visible = useVModel(props, "visible", emits); const visible = useVModel(props, "visible", emits);
const playerRef = ref(null); const playerRef = ref(null);
const fnSrc = (src) => { const fnSrc = (src) => {
if (!src) return;
if (src.indexOf("http") !== -1 || src.indexOf("https") !== -1) return src; if (src.indexOf("http") !== -1 || src.indexOf("https") !== -1) return src;
else return VITE_FILE_URL + src; else return VITE_FILE_URL + src;
}; };

View File

@ -17,3 +17,9 @@ export const getInfo = (params) =>
export const setUploadImg = (params) => upload("/imgfiles/add", params); // 上传附件 export const setUploadImg = (params) => upload("/imgfiles/add", params); // 上传附件
export const setDeleteImg = (params) => post("/imgfiles/delete", params); // 删除附件 export const setDeleteImg = (params) => post("/imgfiles/delete", params); // 删除附件
export const getViewImg = (params) => post("/imgfiles/listImgs", 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); // 获取视频权限

View File

@ -104,7 +104,17 @@
<el-table-column prop="NUMEXAMPLE" label="习题数" /> <el-table-column prop="NUMEXAMPLE" label="习题数" />
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template v-slot="{ row }"> <template v-slot="{ row }">
<el-button type="primary" text link @click="fnOpenVideo(row)"> <el-button
type="primary"
text
link
v-if="
(row.VIDEOCOURSEWARE_ID_REMOTE &&
row.VIDEOCOURSEWARE_ID_REMOTE.length > 0) ||
(row.VIDEOFILES && row.VIDEOFILES.length > 0)
"
@click="fnPreviewVideo(row)"
>
预览 预览
</el-button> </el-button>
<el-button <el-button
@ -136,6 +146,12 @@
</el-table-column> </el-table-column>
</layout-table> </layout-table>
</layout-card> </layout-card>
<layout-video
:src="data.videoDialog.src"
:vid="data.videoDialog.vid"
:play-auth="data.videoDialog.playAuth"
v-model:visible="data.videoDialog.visible"
/>
</div> </div>
</template> </template>
@ -153,6 +169,8 @@ import LayoutTable from "@/components/table/index.vue";
import { debounce } from "throttle-debounce"; import { debounce } from "throttle-debounce";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import LayoutVideo from "@/components/video/index.vue";
import { getVideoAuth, getVideoSource } from "@/request/api.js";
const router = useRouter(); const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } = const { list, pagination, searchForm, fnGetData, fnResetPagination } =
@ -163,8 +181,12 @@ const data = reactive({
{ value: "0", label: "启用" }, { value: "0", label: "启用" },
{ value: "1", label: "禁用" }, { value: "1", label: "禁用" },
], ],
videoVisible: false, videoDialog: {
videoSource: "", src: "",
vid: "",
playAuth: "",
visible: false,
},
}); });
const fnAdd = debounce(1000, async (VIDEOCOURSEWARE_ID) => { const fnAdd = debounce(1000, async (VIDEOCOURSEWARE_ID) => {
@ -174,9 +196,30 @@ const fnAdd = debounce(1000, async (VIDEOCOURSEWARE_ID) => {
fnResetPagination(); fnResetPagination();
}); });
const fnOpenVideo = async () => { const fnPreviewVideo = async (row) => {
// todo if (
ElMessage.info("功能开发中"); 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;
}
}
}; };
</script> </script>