• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py Smooth transition between three videos in Ren'Py with user interaction

UncleNanard

I am to music what Kanye West is to adult games.
Game Developer
Jul 1, 2017
1,413
1,425
Hello,

I am working on a Ren'Py project that requires a specific sequence of three videos.
These videos are actually segments of the same original video (20 sec), each perfectly cut frame-by-frame to be the direct continuation of the previous one:

-First video: Played once.
-Second video (looped): Starts right after the first, played in a loop.
-During the loop of the second video, I call a screen with image buttons and some interactions, while the video continues in the background.
-When the user presses a specific image button, the third video should seamlessly start right at the end of the current loop of the second video.

I am seeking suggestions or solutions for managing this smooth transition in Ren'Py.

Thank you!
 

Satori6

Game Developer
Aug 29, 2023
378
692


Untested, but that should work when combined with a hard pause. The downside is that it seems to fail when they mute the video.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,202
14,938
-When the user presses a specific image button, the third video should seamlessly start right at the end of the current loop of the second video.
Since you already use a screen for the button, you just need a timer coupled to a flag.

This should probably works:
Python:
screen whatever():

    default ready = False

    # Will be triggered only when the video reach its end.
    timer 2ND_VIDEO_DURATION:
        # Repeat, but only if the flag is still lowered.
        repeat ( not ready )
        #  If the flag is raised, stop the current movie and starts the next one.
        # else, do nothing.
        action If( ready, [ Stop( "movie" ), Play( "movie", 3RD_VIDEO_PATH_AND_NAME ) ], NullAction() )

    imagebutton:
        [whatever you already have]
        # Raise the flag
        action SetLocalVariable( "ready", True )

   [whatever else there's in your screen]
If you display the screen right after starting the video, it shouldn't have difference between the moment the video end one loop, and the timer.
 
  • Like
Reactions: UncleNanard

UncleNanard

I am to music what Kanye West is to adult games.
Game Developer
Jul 1, 2017
1,413
1,425
Thank you so much for your help. That's seems to work !

This is what i did :

Python:
screen laundromatloop():
    add Movie(size=(1920, 1080))
    on "show" action Play("movie", "images/bonus2/videos/laundroloop.webm", loop=True)
    on "hide" action Stop("movie")
    on "replace" action Play("movie", "images/bonus2/videos/laundroloop.webm", loop=True)
    on "replaced" action Stop("movie")

    default ready = False

    [lot's of other imagebutton here]

    timer 6.38:

        repeat ( not ready )

        action If( ready,Jump("laundromat2") )

    textbutton("test"):
        action SetLocalVariable( "ready", True )
For the label:

Python:
label laundromat:
    scene bonus2_laundromat4 with dissolve
    nar "dialogue"
    $ renpy.sound.play("audio/muscle_car_loop.ogg", loop=True)
    scene bonus2_laundromat1 with slowdissolve
    nar "dialogue"
    play movie "images/bonus2/videos/laundro1.webm"
    pause 8.38
    call screen laundromatloop

label laundromat2:
    play movie "images/bonus2/videos/laundroend.webm"
    pause 4.5
    stop movie
    scene black with slowdissolve
It's not perfect perfect, sometimes there is a liitle jump, but it's more than enough i think.
I use a pause system, because i m a little bit ashamed to say it, but actually i have no idea how to say to Renpy : Play this video till the end, don't do anything else since.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,202
14,938
i have no idea how to say to Renpy : Play this video till the end, don't do anything else since.
It's the role of , but it's less flexible and usable than displayable. As it name imply, it's designed as pure cut scene, therefore it's the movie, and the movie only. Ren'Py will wait for the movie to end, or for the player to interrupt it, before it process the following statement.
At the opposite, Movie displayable are them designed to act as images, therefore to be displayed on the background, as long as they are relevant in the current scene. What mean that Ren'Py must continue to process the script, like it do when you change an image with show or scene. And like there's people who read faster than others, while there's some who read way slowly, enforcing a duration would be meaningless.

So, in short, everything depend what you intend to do. In the example script you shown, renpy.movie_cutscene should do it, because you're doing nothing else.