视频播放连续跳转下一节优化

This commit is contained in:
禺狨 2023-03-31 09:48:13 +08:00
parent 519907de2a
commit 808cfc67a7
2 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,7 @@ export const HourCompenent: React.FC<PropInterface> = ({
};
const goNextVideo = () => {
const index = totalHours.findIndex((i: any) => i.id === id);
const index = totalHours.findIndex((i: any) => i.id === currentId);
if (index === totalHours.length - 1) {
setIsLastpage(true);
} else if (index < totalHours.length - 1) {

View File

@ -35,6 +35,7 @@ export const VideoModel: React.FC<PropInterface> = ({
const [playDuration, setPlayDuration] = useState(0);
const [playendedStatus, setPlayendedStatus] = useState<Boolean>(false);
const [lastSeeValue, setLastSeeValue] = useState({});
const [loading, setLoading] = useState<Boolean>(false);
const myRef = useRef(0);
useEffect(() => {
@ -94,6 +95,7 @@ export const VideoModel: React.FC<PropInterface> = ({
playTimeUpdate(parseInt(window.player.video.currentTime), true);
window.player && window.player.destroy();
});
setLoading(false);
};
const playTimeUpdate = (duration: number, isEnd: boolean) => {
@ -143,6 +145,10 @@ export const VideoModel: React.FC<PropInterface> = ({
<div
className={styles["alert-button"]}
onClick={() => {
if (loading) {
return;
}
setLoading(true);
setLastSeeValue({});
setPlayendedStatus(false);
goNextVideo();