|
|
@@ -13,20 +13,6 @@
|
|
|
></video>
|
|
|
</template>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- 视频切换按钮 - 始终显示 -->
|
|
|
- <!-- <div class="video-switch">
|
|
|
- <div class="caret-left" @click="playPreviousVideo">
|
|
|
- <el-button type="warning" round>
|
|
|
- <img :src="leftImg" alt="Left" />上一节</el-button
|
|
|
- >
|
|
|
- </div>
|
|
|
- <div class="caret-right" @click="playNextVideo">
|
|
|
- <el-button type="warning" round
|
|
|
- >下一节<img :src="rightImg" alt="Right" />
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -184,30 +170,26 @@ const handleVideoEnded = () => {
|
|
|
// emits('videoEnded')
|
|
|
}
|
|
|
|
|
|
-// // 播放下一个视频
|
|
|
-// 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 setLastPlayPosition = () => {
|
|
|
+ if (!videoRef.value) return
|
|
|
+ try {
|
|
|
+ const savedData = localStorage.getItem(`videoProgress_${props.courseId}`)
|
|
|
+ if (savedData) {
|
|
|
+ const { currentTime, progress } = JSON.parse(savedData)
|
|
|
+ if (currentTime && !isNaN(currentTime)) {
|
|
|
+ videoRef.value.currentTime = currentTime
|
|
|
+ lastPlayProgress.value = progress
|
|
|
+ // 检查是否已有保存的进度点
|
|
|
+ if (progress >= 10) savedProgress.value.push(10)
|
|
|
+ if (progress >= 50) savedProgress.value.push(50)
|
|
|
+ if (progress >= 100) savedProgress.value.push(100)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('读取上次播放进度失败:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 初始化视频播放器
|
|
|
const initVideoPlayer = () => {
|
|
|
@@ -268,26 +250,7 @@ const tryPlayVideo = () => {
|
|
|
}, 1000)
|
|
|
}
|
|
|
|
|
|
-// 在视频加载完成后设置上次播放进度
|
|
|
-const setLastPlayPosition = () => {
|
|
|
- if (!videoRef.value) return
|
|
|
- try {
|
|
|
- const savedData = localStorage.getItem(`videoProgress_${props.courseId}`)
|
|
|
- if (savedData) {
|
|
|
- const { currentTime, progress } = JSON.parse(savedData)
|
|
|
- if (currentTime && !isNaN(currentTime)) {
|
|
|
- videoRef.value.currentTime = currentTime
|
|
|
- lastPlayProgress.value = progress
|
|
|
- // 检查是否已有保存的进度点
|
|
|
- if (progress >= 10) savedProgress.value.push(10)
|
|
|
- if (progress >= 50) savedProgress.value.push(50)
|
|
|
- if (progress >= 100) savedProgress.value.push(100)
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('读取上次播放进度失败:', error)
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
// 组件挂载时
|
|
|
onMounted(() => {
|
|
|
@@ -309,6 +272,7 @@ onBeforeUnmount(() => {
|
|
|
hlsRef.value = null
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@@ -424,47 +388,4 @@ onBeforeUnmount(() => {
|
|
|
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);
|
|
|
-// }
|
|
|
</style>
|