Skip to content

Commit

Permalink
Fix video playback issue and store last player time in cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddybiovlsi committed Mar 19, 2024
1 parent aaf4467 commit 1546591
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/components/VideoJS.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ export const VideoJS = (props) => {
});
player.on("play", () => {
console.log("sendState", sendstate);
if (type !== 2) {
timer = setInterval(() => {
lastPlayerTime = player.currentTime();
console.log("lastPlayerTime", lastPlayerTime);
console.log("player.currentTime()", player.currentTime());

timer = setInterval(() => {
lastPlayerTime = player.currentTime();
console.log("lastPlayerTime", lastPlayerTime);
console.log("player.currentTime()", player.currentTime());

// store the current time of the video in the cookie
document.cookie = `lastPlayerTime=${lastPlayerTime}`;
}, 1000);
// store the current time of the video in the cookie
document.cookie = `lastPlayerTime=${lastPlayerTime}`;
}, 1000);
}

// console.log("player is play");
});
Expand All @@ -151,16 +152,18 @@ export const VideoJS = (props) => {
});

player.on("timeupdate", () => {
if (arrayNum < info.length) {
if (player.currentTime() >= info[arrayNum].video_interrupt_time) {
player.pause();
setSendstate(true);
setTimeout(() => {
setSendstate(false);
player.play();
}, info[arrayNum].video_duration * 1000);
arrayNum++;
}
if (
type !== 2 &&
arrayNum < info.length &&
player.currentTime() >= info[arrayNum].video_interrupt_time
) {
player.pause();
setSendstate(true);
setTimeout(() => {
setSendstate(false);
player.play();
}, info[arrayNum].video_duration * 1000);
arrayNum++;
}
});

Expand Down

0 comments on commit 1546591

Please sign in to comment.