Merge pull request #2 from PlayEdu/dev

视频播放优化
This commit is contained in:
Teng 2023-07-05 11:30:59 +08:00 committed by GitHub
commit 09072ac16f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,11 +85,14 @@ const CoursePlayPage = () => {
setTotalHours(arr); setTotalHours(arr);
totalHours = arr; totalHours = arr;
} }
//判断是否是最后的课时
const index = totalHours.findIndex( const index = totalHours.findIndex(
(i: any) => i.id === Number(params.hourId) (i: any) => i.id === Number(params.hourId)
); );
if (index === totalHours.length - 1) { if (index === totalHours.length - 1) {
setIsLastpage(true); setIsLastpage(true);
} else {
setIsLastpage(false);
} }
}); });
}; };
@ -186,11 +189,11 @@ const CoursePlayPage = () => {
window.player.seek(playRef.current); window.player.seek(playRef.current);
return; return;
} }
setPlayendedStatus(true);
setPlayingTime(0); setPlayingTime(0);
playTimeUpdate(parseInt(window.player.video.currentTime), true); playTimeUpdate(parseInt(window.player.video.currentTime), true);
exitFullscreen(); exitFullscreen();
window.player && window.player.destroy(); window.player && window.player.destroy();
setPlayendedStatus(true);
}); });
setLoading(false); setLoading(false);
}; };
@ -217,6 +220,7 @@ const CoursePlayPage = () => {
setIsLastpage(true); setIsLastpage(true);
Toast.show("已经是最后一节了!"); Toast.show("已经是最后一节了!");
} else if (index < totalHours.length - 1) { } else if (index < totalHours.length - 1) {
setIsLastpage(false);
navigate(`/course/${params.courseId}/hour/${totalHours[index + 1].id}`, { navigate(`/course/${params.courseId}/hour/${totalHours[index + 1].id}`, {
replace: true, replace: true,
}); });
@ -251,7 +255,11 @@ const CoursePlayPage = () => {
}} }}
/> />
<div className={styles["video-box"]}> <div className={styles["video-box"]}>
<div className="play-box" id="meedu-player-container"></div> <div
className="play-box"
style={{ display: playendedStatus ? "none" : "block" }}
id="meedu-player-container"
></div>
{playendedStatus && ( {playendedStatus && (
<div className={styles["alert-message"]}> <div className={styles["alert-message"]}>
{isLastpage && ( {isLastpage && (