mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-07 20:45:38 +08:00
已看完视频显示进度条
This commit is contained in:
parent
c8e9f8cc7a
commit
cec5251da4
@ -27,6 +27,7 @@ const CoursePalyPage = () => {
|
||||
const myRef = useRef(0);
|
||||
const playRef = useRef(0);
|
||||
const watchRef = useRef(0);
|
||||
const totalRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
getCourse();
|
||||
@ -57,6 +58,10 @@ const CoursePalyPage = () => {
|
||||
watchRef.current = watchedSeconds;
|
||||
}, [watchedSeconds]);
|
||||
|
||||
useEffect(() => {
|
||||
totalRef.current = hour.duration;
|
||||
}, [hour]);
|
||||
|
||||
const getCourse = () => {
|
||||
Course.detail(Number(params.courseId)).then((res: any) => {
|
||||
let totalHours: any = [];
|
||||
@ -102,6 +107,8 @@ const CoursePalyPage = () => {
|
||||
setLastSeeValue(params);
|
||||
setLastSeeValue(params);
|
||||
setWatchedSeconds(record.finished_duration);
|
||||
} else {
|
||||
setWatchedSeconds(res.data.hour.duration);
|
||||
}
|
||||
getVideoUrl(params);
|
||||
setLoading(false);
|
||||
@ -121,6 +128,10 @@ const CoursePalyPage = () => {
|
||||
};
|
||||
|
||||
const initDPlayer = (playUrl: string, isTrySee: number, params: any) => {
|
||||
let banDrag =
|
||||
systemConfig.playerIsDisabledDrag && watchRef.current < totalRef.current;
|
||||
console.log(watchRef.current);
|
||||
console.log(totalRef.current);
|
||||
window.player = new window.DPlayer({
|
||||
container: document.getElementById("meedu-player-container"),
|
||||
autoplay: false,
|
||||
@ -139,14 +150,14 @@ const CoursePalyPage = () => {
|
||||
color: systemConfig.playerBulletSecretColor || "red",
|
||||
opacity: Number(systemConfig.playerBulletSecretOpacity),
|
||||
},
|
||||
ban_drag: systemConfig.playerIsDisabledDrag,
|
||||
ban_drag: banDrag,
|
||||
last_see_pos: params,
|
||||
});
|
||||
// 监听播放进度更新evt
|
||||
window.player.on("timeupdate", () => {
|
||||
let currentTime = parseInt(window.player.video.currentTime);
|
||||
if (
|
||||
systemConfig.playerIsDisabledDrag &&
|
||||
banDrag &&
|
||||
currentTime - playRef.current >= 2 &&
|
||||
currentTime > watchRef.current
|
||||
) {
|
||||
@ -157,10 +168,7 @@ const CoursePalyPage = () => {
|
||||
}
|
||||
});
|
||||
window.player.on("ended", () => {
|
||||
if (
|
||||
systemConfig.playerIsDisabledDrag &&
|
||||
window.player.video.duration - playRef.current >= 2
|
||||
) {
|
||||
if (banDrag && window.player.video.duration - playRef.current >= 2) {
|
||||
window.player.seek(playRef.current);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user