Skip to content

Commit

Permalink
- videoplayer update
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislav-serdyuk committed Jul 17, 2024
1 parent ea238b0 commit d9a6b37
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pkg/videoplayer/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,33 @@ def __call__(self, img):
fps = self.video.get(cv2.CAP_PROP_FPS)
self.new_time += 1 / fps
ret, frame = self.video.read()
while time.time() >= self.new_time:
self.new_time += 1 / fps
ret, frame = self.video.read()
if not ret:
self.stop()
else:
h, w, c = frame.shape
self.frame = cv2.resize(frame, dsize=(w * (self.windows_height + self.height_moving_area) // h,
self.windows_height + self.height_moving_area))
new_h = self.windows_height - 35
new_w = w * new_h // h
self.window_width = new_w
self.frame = cv2.resize(frame, dsize=(new_w, new_h))

if self.hide:
return

for i, file in enumerate(self.video_files):
self.button(img, 5, i * 35 + 5, self.window_width - 10, 30, file, (200, 255, 200),
lambda f=file: self.set_select(f))

self.text(img, 10, self.windows_height - 60, self.select, (0, 0, 0))
if self.is_play:
pass
else:
for i, file in enumerate(self.video_files):
self.button(img, 5, i * 35 + 5, self.window_width - 10, 30, file, (200, 255, 200),
lambda f=file: self.set_select(f))
self.text(img, 10, self.windows_height - 60, self.select, (0, 0, 0))

if self.is_play:
self.button(img, 5, self.windows_height - 35, self.window_width - 10, 35, 'Stop', (0, 0, 255),
lambda: self.stop())
self.add_img(img, self.window_width + 5, 0, self.frame)
self.add_img(img, 0, 0, self.frame)
else:
self.button(img, 5, self.windows_height - 35, self.window_width - 10, 35, 'Play', (0, 255, 0),
lambda: self.play())
Expand All @@ -86,3 +93,4 @@ def play(self):
def stop(self):
self.is_play = False
self.player.close_player()
self.window_width = 250

0 comments on commit d9a6b37

Please sign in to comment.