Skip to content

Commit 199f332

Browse files
committed
Fix animation reset after saving to mp4 bug
Previously saving an animation through `.save()` was only possible once. This patch resets the object properly so that `save()` can be called again
1 parent f2fe773 commit 199f332

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

optimap/video/_player.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,17 @@ def save(self, *args, hide_slider=True, hide_buttons=True, hide_framecounter=Fal
186186
self.i = self.min - self.step
187187
self.saving = True
188188
self._save_count = (self.max - self.min) // self.step
189-
if hide_buttons:
190-
self.ax_player.set_visible(False)
191-
if hide_slider:
192-
self.ax_slider.set_visible(False)
193-
if hide_framecounter:
194-
self.suptitle.set_visible(False)
195-
super().save(*args, **kwargs)
189+
self.ax_player.set_visible(not hide_buttons)
190+
self.ax_slider.set_visible(not hide_slider)
191+
self.suptitle.set_visible(not hide_framecounter)
196192

193+
super().save(*args, **kwargs)
194+
197195
self.saving = False
196+
# reset frame generator, it's exhausted now
197+
self._iter_gen = self.play
198198
self._save_count = None
199+
199200
self.ax_player.set_visible(True)
200201
self.ax_slider.set_visible(True)
201202
self.suptitle.set_visible(True)

0 commit comments

Comments
 (0)