Skip to content

Commit

Permalink
force a playback rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Feb 26, 2025
1 parent 9058440 commit e380d97
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/frontend/components/atoms/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function Loading({
if (!videoRef.current) {
return;
}
videoRef.current.playbackRate = 2;
videoRef.current.addEventListener("ended", () => {
console.log("Loading ended");
if (videoRef.current?.currentTime === VIDEO_TIME_S) {
Expand All @@ -41,16 +42,13 @@ export function Loading({
}
if (progress === undefined) {
console.log("No progress, playing at full rate");
videoRef.current.playbackRate = 2;
videoRef.current.play();
return;
}
const expectedProgress = VIDEO_TIME_S * progress;
const currentTime = videoRef.current.currentTime;
if (expectedProgress > currentTime) {
console.log("Progress behind", currentTime, expectedProgress);
videoRef.current.playbackRate =
expectedProgress - currentTime > 2 ? 3 : 1;
videoRef.current.play();
} else if (currentTime >= expectedProgress) {
console.log("Progress ahead of current time, pausing", currentTime, expectedProgress);
Expand Down

0 comments on commit e380d97

Please sign in to comment.