Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lib): add playback rate config options #320

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 91bed3257c509fe04c34bde9661db9f12a61216d
4 changes: 1 addition & 3 deletions manim_slides/__main__.py
Original file line number Diff line number Diff line change
@@ -34,9 +34,7 @@ def cli(notify_outdated_version: bool) -> None:
manim_info_url = "https://pypi.org/pypi/manim-slides/json"
warn_prompt = "Cannot check if latest release of Manim Slides is installed"
try:
req_info: requests.models.Response = requests.get(
manim_info_url, timeout=2
)
req_info: requests.models.Response = requests.get(manim_info_url, timeout=2)
req_info.raise_for_status()
stable = req_info.json()["info"]["version"]
if stable != __version__:
4 changes: 3 additions & 1 deletion manim_slides/present/player.py
Original file line number Diff line number Diff line change
@@ -237,7 +237,9 @@ def load_current_media(self, start_paused: bool = False) -> None:
self.media_player.setSource(url)

if self.playing_reversed_slide:
self.media_player.setPlaybackRate(self.current_slide_config.reversed_playback_rate)
self.media_player.setPlaybackRate(
self.current_slide_config.reversed_playback_rate
)
else:
self.media_player.setPlaybackRate(self.current_slide_config.playback_rate)

15 changes: 13 additions & 2 deletions manim_slides/slide/base.py
Original file line number Diff line number Diff line change
@@ -255,7 +255,13 @@ def play(self, *args: Any, **kwargs: Any) -> None:
self._current_animation += 1

def next_slide(
self, *, loop: bool = False, auto_next: bool = False, playback_rate: float = 1.0, reversed_playback_rate: float = 1.0, **kwargs: Any
self,
*,
loop: bool = False,
auto_next: bool = False,
playback_rate: float = 1.0,
reversed_playback_rate: float = 1.0,
**kwargs: Any,
) -> None:
"""
Create a new slide with previous animations, and setup options
@@ -383,7 +389,12 @@ def construct(self):

self._current_slide += 1

self._pre_slide_config_kwargs = dict(loop=loop, auto_next=auto_next, playback_rate=playback_rate, reversed_playback_rate=reversed_playback_rate)
self._pre_slide_config_kwargs = dict(
loop=loop,
auto_next=auto_next,
playback_rate=playback_rate,
reversed_playback_rate=reversed_playback_rate,
)
self._start_animation = self._current_animation

def _add_last_slide(self) -> None:
16 changes: 14 additions & 2 deletions manim_slides/slide/manim.py
Original file line number Diff line number Diff line change
@@ -80,10 +80,22 @@ def next_section(self, *args: Any, **kwargs: Any) -> None:
self.next_slide(*args, **kwargs)

def next_slide(
self, *args: Any, loop: bool = False, auto_next: bool = False, playback_rate: float = 1.0, reversed_playback_rate: float = 1.0, **kwargs: Any
self,
*args: Any,
loop: bool = False,
auto_next: bool = False,
playback_rate: float = 1.0,
reversed_playback_rate: float = 1.0,
**kwargs: Any,
) -> None:
Scene.next_section(self, *args, **kwargs)
BaseSlide.next_slide(self, loop=loop, auto_next=auto_next, playback_rate=playback_rate, reversed_playback_rate=reversed_playback_rate)
BaseSlide.next_slide(
self,
loop=loop,
auto_next=auto_next,
playback_rate=playback_rate,
reversed_playback_rate=reversed_playback_rate,
)

def render(self, *args: Any, **kwargs: Any) -> None:
"""MANIM render."""
1 change: 0 additions & 1 deletion tests/test_slide.py
Original file line number Diff line number Diff line change
@@ -196,7 +196,6 @@ def construct(self) -> None:

assert self._pre_slide_config_kwargs["playback_rate"] == 2.0


@assert_constructs
class TestWipe(Slide):
def construct(self) -> None: