Skip to content

Commit

Permalink
signalling from viewer_display to controller to extend time if video …
Browse files Browse the repository at this point in the history
…longer
  • Loading branch information
paddywwoof committed Nov 21, 2024
1 parent fadf045 commit 4b8aebc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/picframe/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def loop(self): # TODO exit loop gracefully and call image_cache.stop()
# catch ctrl-c
signal.signal(signal.SIGINT, self.__signal_handler)

video_extended = False
while self.keep_looping:
time_delay = self.__model.time_delay
fade_time = self.__model.fade_time
Expand All @@ -289,12 +290,16 @@ def loop(self): # TODO exit loop gracefully and call image_cache.stop()
image_attr[key] = pics[0].__dict__[field_name] # TODO nicer using namedtuple for Pic
if self.__mqtt_config['use_mqtt']:
self.publish_state(pics[0].fname, image_attr)
video_extended = False
self.__model.pause_looping = self.__viewer.is_in_transition()
(loop_running, skip_image) = self.__viewer.slideshow_is_running(pics, time_delay, fade_time, self.__paused)
(loop_running, skip_image, video_time) = self.__viewer.slideshow_is_running(pics, time_delay, fade_time, self.__paused)
if not loop_running:
break
if skip_image:
self.__next_tm = 0
if video_time is not None and not video_extended: # signal to extend __next_tm for this video, only do this once per video
video_extended = True
self.__next_tm += (video_time - time_delay) # increase by required amount
self.__interface_peripherals.check_input()

def start(self):
Expand Down
7 changes: 6 additions & 1 deletion src/picframe/viewer_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,12 @@ def slideshow_is_running(self, pics=None, time_delay=200.0, fade_time=10.0, paus
if block is not None:
block.sprite.draw()

return (loop_running, skip_image) # now returns tuple with skip image flag added
video_time = None
if self.__video_streamer is not None:
video_duration = self.__video_streamer.duration * self.__video_streamer.fps / self.__fps
if video_duration > time_delay:
video_time = video_duration
return (loop_running, skip_image, video_time) # now returns tuple with skip_image flag and video_time added

def slideshow_stop(self):
if self.__video_streamer is not None:
Expand Down

0 comments on commit 4b8aebc

Please sign in to comment.