From 47b190bbf047a073509a25bdfba05fa20f91a4fd Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 19 Aug 2025 08:11:19 +0200 Subject: [PATCH] fix(main.py): conditionally display info overlay and timeline for video files only --- main.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index a332113..ad9081a 100644 --- a/main.py +++ b/main.py @@ -167,20 +167,21 @@ class MediaGrader: # Add info overlay current_file = self.media_files[self.current_index] - info_text = f"Speed: {self.playback_speed:.1f}x | Frame: {self.current_frame}/{self.total_frames} | File: {self.current_index + 1}/{len(self.media_files)} | {'Playing' if self.is_playing else 'PAUSED'}" + if self.is_video(self.media_files[self.current_index]): + info_text = f"Speed: {self.playback_speed:.1f}x | Frame: {self.current_frame}/{self.total_frames} | File: {self.current_index + 1}/{len(self.media_files)} | {'Playing' if self.is_playing else 'PAUSED'}" - cv2.putText( - frame, - info_text, - (10, 30), - cv2.FONT_HERSHEY_SIMPLEX, - 0.7, - (255, 255, 255), - 2, - ) - cv2.putText( - frame, info_text, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 1 - ) + cv2.putText( + frame, + info_text, + (10, 30), + cv2.FONT_HERSHEY_SIMPLEX, + 0.7, + (255, 255, 255), + 2, + ) + cv2.putText( + frame, info_text, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 1 + ) # Draw timeline self.draw_timeline(frame) @@ -189,6 +190,10 @@ class MediaGrader: def draw_timeline(self, frame): """Draw timeline at the bottom of the frame""" + # Only draw timeline for video files + if not self.is_video(self.media_files[self.current_index]): + return + height, width = frame.shape[:2] self.window_height = height self.window_width = width @@ -210,7 +215,7 @@ class MediaGrader: cv2.rectangle(frame, (bar_x_start, bar_y), (bar_x_end, bar_y + self.TIMELINE_BAR_HEIGHT), self.TIMELINE_COLOR_BORDER, 1) # Draw progress for videos - if self.is_video(self.media_files[self.current_index]) and self.total_frames > 0: + if self.total_frames > 0: progress = self.current_frame / max(1, self.total_frames - 1) progress_width = int(bar_width * progress) if progress_width > 0: