Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions examples/rgb_display_pillow_animated_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def preload(self):
def play(self):
self.preload()

_prev_advance_btn_val = self.advance_button.value
_prev_back_btn_val = self.back_button.value
# Check if we have loaded any files first
if not self._gif_files:
print("There are no Gif Images loaded to Play")
Expand All @@ -141,12 +143,17 @@ def play(self):
for frame_object in self._frames:
start_time = time.monotonic()
self.display.image(frame_object.image)
if not self.advance_button.value:
_cur_advance_btn_val = self.advance_button.value
_cur_back_btn_val = self.back_button.value
if not _cur_advance_btn_val and _prev_advance_btn_val:
self.advance()
return False
if not self.back_button.value:
if not _cur_back_btn_val and _prev_back_btn_val:
self.back()
return False

_prev_back_btn_val = _cur_back_btn_val
_prev_advance_btn_val = _cur_advance_btn_val
while time.monotonic() < (start_time + frame_object.duration / 1000):
pass

Expand Down