|
|
@@ -1,7 +1,6 @@
|
|
|
<template>
|
|
|
<div class="video-container">
|
|
|
<div class="box-video">
|
|
|
- <!-- 根据contentType决定显示视频、图片、PPT -->
|
|
|
<!-- 视频 -->
|
|
|
<template v-if="contentType === 'video'">
|
|
|
<video
|
|
|
@@ -13,31 +12,10 @@
|
|
|
@ended="handleVideoEnded"
|
|
|
></video>
|
|
|
</template>
|
|
|
- <!-- 图片 -->
|
|
|
- <template v-else-if="contentType === 'image'">
|
|
|
- <div class="image-container">
|
|
|
- <img :src="imagePath" alt="课程图片" class="course-image" />
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <!-- PPT -->
|
|
|
- <template v-else-if="contentType === 'ppt' || contentType === 'pptx'">
|
|
|
- <div class="ppt-box">
|
|
|
- <VueOfficePptx class="ppt-container" :src="pptPath" @error="handlePptError" @rendered="handlePptRendered" />
|
|
|
- <!-- PPT页码显示 -->
|
|
|
- <div class="ppt-page-info">
|
|
|
- {{ currentPage }}/{{ totalPages }}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!-- PPT翻页按钮 -->
|
|
|
- <div class="ppt-navigation">
|
|
|
- <button @click="prevPage" class="ppt-btn ppt-prev-btn">上一页</button>
|
|
|
- <button @click="nextPage" class="ppt-btn ppt-next-btn">下一页</button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
</div>
|
|
|
|
|
|
<!-- 视频切换按钮 - 始终显示 -->
|
|
|
- <div class="video-switch">
|
|
|
+ <!-- <div class="video-switch">
|
|
|
<div class="caret-left" @click="playPreviousVideo">
|
|
|
<el-button type="warning" round>
|
|
|
<img :src="leftImg" alt="Left" />上一节</el-button
|
|
|
@@ -48,7 +26,7 @@
|
|
|
>下一节<img :src="rightImg" alt="Right" />
|
|
|
</el-button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -72,16 +50,12 @@ import { globalState } from '@/utils/globalState.js'
|
|
|
import leftImg from '@/assets/icon/backward.png'
|
|
|
import rightImg from '@/assets/icon/f-backward.png'
|
|
|
import { saveRecord } from '@/api/personalized/index.js'
|
|
|
-// PPT
|
|
|
-import VueOfficePptx from '@vue-office/pptx'
|
|
|
-// import '@vue-office/pptx/lib/index.css'
|
|
|
+
|
|
|
|
|
|
// 定义props
|
|
|
const props = defineProps({
|
|
|
contentType: { type: String, required: true }, // contentType类型
|
|
|
videoPath: { type: String }, // 变为可选
|
|
|
- imagePath: { type: String }, // 图片路径
|
|
|
- pptPath: { type: String }, // PPT路径
|
|
|
courseId: { type: String, required: true },
|
|
|
typeId: { type: String, required: true },
|
|
|
courseConfigList: { type: Array, default: () => [] },
|
|
|
@@ -106,9 +80,6 @@ const THROTTLE_TIME = 3000
|
|
|
const lastPlayProgress = ref(0)
|
|
|
// 定义进度数组
|
|
|
const targetProgresses = [10, 50, 100]
|
|
|
-// PPT
|
|
|
-const totalPages = ref(1)
|
|
|
-const currentPage = ref(1)
|
|
|
|
|
|
// 定义节流函数
|
|
|
const throttle = (fn, delay) => {
|
|
|
@@ -213,60 +184,30 @@ const handleVideoEnded = () => {
|
|
|
// emits('videoEnded')
|
|
|
}
|
|
|
|
|
|
-// 处理PPT渲染完成事件
|
|
|
-const handlePptRendered = (pptInfo) => {
|
|
|
- console.log('PPT渲染完成');
|
|
|
- // 增强的页数检测逻辑
|
|
|
- const pageCount = pptInfo?.slides?.length ||
|
|
|
- pptInfo?.pageCount ||
|
|
|
- pptInfo?.totalSlides ||
|
|
|
- (pptInfo?.slideCount ? parseInt(pptInfo.slideCount) : 1);
|
|
|
- totalPages.value = pageCount;
|
|
|
- // 确保当前页在有效范围内
|
|
|
- if (currentPage.value > pageCount) {
|
|
|
- currentPage.value = pageCount;
|
|
|
- }
|
|
|
- console.log('PPT总页数:', pageCount, '当前页:', currentPage.value);
|
|
|
-}
|
|
|
-// PPT错误处理事件
|
|
|
-const handlePptError = (error) => {
|
|
|
- console.error('PPT加载错误:', error)
|
|
|
- ElMessage.error('PPT加载失败,请检查文件路径或格式')
|
|
|
-}
|
|
|
-// 上一页
|
|
|
-const prevPage = () =>{
|
|
|
- console.log('上一页');
|
|
|
-}
|
|
|
-// 下一页
|
|
|
-const nextPage = () =>{
|
|
|
- console.log('下一页');
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// 播放下一个视频
|
|
|
-const playNextVideo = () => {
|
|
|
- const currentIndexInList = props.allIndices.indexOf(props.currentIndex)
|
|
|
- if (
|
|
|
- currentIndexInList !== -1 &&
|
|
|
- currentIndexInList < props.allIndices.length - 1
|
|
|
- ) {
|
|
|
- const nextIndex = props.allIndices[currentIndexInList + 1]
|
|
|
- emits('switchVideo', nextIndex)
|
|
|
- // 重置暂停索引
|
|
|
- pausedIndices.value = []
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 播放上一个视频
|
|
|
-const playPreviousVideo = () => {
|
|
|
- const currentIndexInList = props.allIndices.indexOf(props.currentIndex)
|
|
|
- if (currentIndexInList > 0) {
|
|
|
- const previousIndex = props.allIndices[currentIndexInList - 1]
|
|
|
- emits('switchVideo', previousIndex)
|
|
|
- // 重置暂停索引
|
|
|
- pausedIndices.value = []
|
|
|
- }
|
|
|
-}
|
|
|
+// // 播放下一个视频
|
|
|
+// const playNextVideo = () => {
|
|
|
+// const currentIndexInList = props.allIndices.indexOf(props.currentIndex)
|
|
|
+// if (
|
|
|
+// currentIndexInList !== -1 &&
|
|
|
+// currentIndexInList < props.allIndices.length - 1
|
|
|
+// ) {
|
|
|
+// const nextIndex = props.allIndices[currentIndexInList + 1]
|
|
|
+// emits('switchVideo', nextIndex)
|
|
|
+// // 重置暂停索引
|
|
|
+// pausedIndices.value = []
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// // 播放上一个视频
|
|
|
+// const playPreviousVideo = () => {
|
|
|
+// const currentIndexInList = props.allIndices.indexOf(props.currentIndex)
|
|
|
+// if (currentIndexInList > 0) {
|
|
|
+// const previousIndex = props.allIndices[currentIndexInList - 1]
|
|
|
+// emits('switchVideo', previousIndex)
|
|
|
+// // 重置暂停索引
|
|
|
+// pausedIndices.value = []
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
// 初始化视频播放器
|
|
|
const initVideoPlayer = () => {
|
|
|
@@ -484,46 +425,46 @@ video::-webkit-media-controls-panel {
|
|
|
background: transparent !important; /* 去掉背景渐变,设为透明 */
|
|
|
}
|
|
|
|
|
|
-.video-switch {
|
|
|
- width: 100%;
|
|
|
- display: flex;
|
|
|
- margin-top: rpx(5);
|
|
|
- margin-bottom: rpx(15);
|
|
|
-}
|
|
|
-.image-container {
|
|
|
- width: 100%;
|
|
|
- height: rpx(300);
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
-}
|
|
|
-.course-image {
|
|
|
- max-width: 70%;
|
|
|
- max-height: rpx(289);
|
|
|
- border-radius: rpx(12);
|
|
|
- object-fit: contain;
|
|
|
-}
|
|
|
-.caret-right,
|
|
|
-.caret-left {
|
|
|
- width: rpx(50);
|
|
|
- margin: auto;
|
|
|
- display: flex;
|
|
|
-}
|
|
|
-
|
|
|
-.caret-left ::v-deep(.el-button.is-round),
|
|
|
-.caret-right ::v-deep(.el-button.is-round) {
|
|
|
- width: rpx(50);
|
|
|
- height: rpx(15);
|
|
|
- color: white;
|
|
|
- font-size: rpx(7);
|
|
|
- border-radius: none;
|
|
|
- border: 1px white solid;
|
|
|
- background-color: rgb(255, 255, 255, 0.5);
|
|
|
- box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
|
|
|
-}
|
|
|
-
|
|
|
-.caret-right img,
|
|
|
-.caret-left img {
|
|
|
- width: rpx(12);
|
|
|
-}
|
|
|
+// .video-switch {
|
|
|
+// width: 100%;
|
|
|
+// display: flex;
|
|
|
+// margin-top: rpx(5);
|
|
|
+// margin-bottom: rpx(15);
|
|
|
+// }
|
|
|
+// .image-container {
|
|
|
+// width: 100%;
|
|
|
+// height: rpx(300);
|
|
|
+// display: flex;
|
|
|
+// justify-content: center;
|
|
|
+// align-items: center;
|
|
|
+// }
|
|
|
+// .course-image {
|
|
|
+// max-width: 70%;
|
|
|
+// max-height: rpx(289);
|
|
|
+// border-radius: rpx(12);
|
|
|
+// object-fit: contain;
|
|
|
+// }
|
|
|
+// .caret-right,
|
|
|
+// .caret-left {
|
|
|
+// width: rpx(50);
|
|
|
+// margin: auto;
|
|
|
+// display: flex;
|
|
|
+// }
|
|
|
+
|
|
|
+// .caret-left ::v-deep(.el-button.is-round),
|
|
|
+// .caret-right ::v-deep(.el-button.is-round) {
|
|
|
+// width: rpx(50);
|
|
|
+// height: rpx(15);
|
|
|
+// color: white;
|
|
|
+// font-size: rpx(7);
|
|
|
+// border-radius: none;
|
|
|
+// border: 1px white solid;
|
|
|
+// background-color: rgb(255, 255, 255, 0.5);
|
|
|
+// box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
|
|
|
+// }
|
|
|
+
|
|
|
+// .caret-right img,
|
|
|
+// .caret-left img {
|
|
|
+// width: rpx(12);
|
|
|
+// }
|
|
|
</style>
|