Skip to content

Commit

Permalink
Fix animation reset after saving to mp4 bug
Browse files Browse the repository at this point in the history
Previously saving an animation through `.save()` was only possible once. This patch resets the object properly so that `save()` can be called again
  • Loading branch information
sitic committed May 23, 2024
1 parent f2fe773 commit 199f332
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions optimap/video/_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,17 @@ def save(self, *args, hide_slider=True, hide_buttons=True, hide_framecounter=Fal
self.i = self.min - self.step
self.saving = True
self._save_count = (self.max - self.min) // self.step
if hide_buttons:
self.ax_player.set_visible(False)
if hide_slider:
self.ax_slider.set_visible(False)
if hide_framecounter:
self.suptitle.set_visible(False)
super().save(*args, **kwargs)
self.ax_player.set_visible(not hide_buttons)
self.ax_slider.set_visible(not hide_slider)
self.suptitle.set_visible(not hide_framecounter)

super().save(*args, **kwargs)

self.saving = False
# reset frame generator, it's exhausted now
self._iter_gen = self.play
self._save_count = None

self.ax_player.set_visible(True)
self.ax_slider.set_visible(True)
self.suptitle.set_visible(True)

0 comments on commit 199f332

Please sign in to comment.