Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Leterax committed Dec 2, 2024
1 parent e2ff460 commit d95260a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions examples/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def frames(self) -> int:

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.container.close()

def close(self):
"""Explicitly close the video container."""
self.container.close()
Expand Down Expand Up @@ -143,7 +143,7 @@ def update(self, time: float) -> bool:
if frame_diff > self.FRAME_DIFF_THRESHOLD:
self._behind_count += 1
skip_to = min(self._target_frame - self.SKIP_OFFSET, self.frames - 1)

if self._behind_count > self.MAX_BEHIND_COUNT:
self._decoder.seek(skip_to / self.fps)
self._frames = self._decoder.get_frames()
Expand Down Expand Up @@ -209,7 +209,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

# Initialize video player
video_path = self.resource_dir / "videos" / "Lightning - 33049.mp4"
video_path = self.resource_dir / "videos" / "Lightning - 33049.mp4"
# video_path = r"C:\Users\Leo Mintech\Downloads\Countdown_Overlay_Timer_10_Minutes.mp4"

self.player = VideoPlayer(self.ctx, video_path)
Expand Down Expand Up @@ -251,7 +251,7 @@ def _handle_seek(self, direction: Literal["forward", "backward"]) -> None:
"""Handle seeking in video. direction: 'forward' or 'backward'"""
seek_amount = self.seek_time if direction == "forward" else -self.seek_time
new_time = max(0, min(self.player.duration, self.timer.time + seek_amount))

if self.timer.is_paused:
self.player.seek(new_time)
else:
Expand Down
4 changes: 2 additions & 2 deletions moderngl_window/timers/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ def next_frame(self) -> tuple[float, float]:
self._frames += 1
current = self.time
delta, self._last_frame = current - self._last_frame, current

# Avoid division by zero on first frame
if delta > 0:
self._fps = 1.0 / delta
else:
self._fps = 0.0

return current, delta

def start(self) -> None:
Expand Down

0 comments on commit d95260a

Please sign in to comment.