mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-07-15 00:52:15 +08:00
feat(cli): add next-terminates-loop
CLI option (#299)
* feat(cli): add `next-terminates-loop` CLI option Closes #254 * chore(lib): fix `--next-terminates-loop` * chore(CHANGELOG): document changes
This commit is contained in:
@ -219,6 +219,12 @@ def start_at_callback(
|
||||
default=1.0,
|
||||
help="Playback rate of the video slides, see PySide6 docs for details.",
|
||||
)
|
||||
@click.option(
|
||||
"--next-terminates-loop",
|
||||
"next_terminates_loop",
|
||||
is_flag=True,
|
||||
help="If set, pressing next will turn any looping slide into a play slide.",
|
||||
)
|
||||
@click.help_option("-h", "--help")
|
||||
@verbosity_option
|
||||
def present(
|
||||
@ -234,8 +240,9 @@ def present(
|
||||
start_at: Tuple[Optional[int], Optional[int], Optional[int]],
|
||||
start_at_scene_number: int,
|
||||
start_at_slide_number: int,
|
||||
screen_number: Optional[int] = None,
|
||||
playback_rate: float = 1.0,
|
||||
screen_number: Optional[int],
|
||||
playback_rate: float,
|
||||
next_terminates_loop: bool,
|
||||
) -> None:
|
||||
"""
|
||||
Present SCENE(s), one at a time, in order.
|
||||
@ -296,6 +303,7 @@ def present(
|
||||
slide_index=start_at_slide_number,
|
||||
screen=screen,
|
||||
playback_rate=playback_rate,
|
||||
next_terminates_loop=next_terminates_loop,
|
||||
)
|
||||
|
||||
player.show()
|
||||
|
@ -54,6 +54,7 @@ class Player(QMainWindow): # type: ignore[misc]
|
||||
slide_index: int = 0,
|
||||
screen: Optional[QScreen] = None,
|
||||
playback_rate: float = 1.0,
|
||||
next_terminates_loop: bool = False,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
@ -125,6 +126,7 @@ class Player(QMainWindow): # type: ignore[misc]
|
||||
# Misc
|
||||
|
||||
self.exit_after_last_slide = exit_after_last_slide
|
||||
self.next_terminates_loop = next_terminates_loop
|
||||
|
||||
# Setting-up everything
|
||||
|
||||
@ -313,6 +315,12 @@ class Player(QMainWindow): # type: ignore[misc]
|
||||
def next(self) -> None:
|
||||
if self.media_player.playbackState() == QMediaPlayer.PausedState:
|
||||
self.media_player.play()
|
||||
elif self.next_terminates_loop and self.media_player.loops() != 1:
|
||||
position = self.media_player.position()
|
||||
self.media_player.setLoops(1)
|
||||
self.media_player.stop()
|
||||
self.media_player.setPosition(position)
|
||||
self.media_player.play()
|
||||
else:
|
||||
self.load_next_slide()
|
||||
|
||||
|
Reference in New Issue
Block a user