How do I make videos in Ren'py move on to the next screen when the video ends?

Leeuwenhoek

Newbie
Nov 21, 2018
23
25
Hello programmers I am new to Ren'py programming and I have some issues with videos. I would like to keep the text window open for the progression of the story while the video is playing in the background and when the video ends have it automatically move on to the next screen instead of the video looping. I can't seem to figure this out unless the video is in the foreground and controls the whole screen without the text window being active. I looked everywhere but I can't seem to find a solution to this problem. Any help would be greatly appreciated. Thanks
 

Higurashika

Well-Known Member
Nov 15, 2018
1,380
1,981
Just use videos as backgrounds. So they will be as images for renpy and you can do with them all you want.
You just set the parameters, for example:
Code:
image movie1 = Movie(play="images/video/koshka_lenina.ogv", size=(1920, 1080))
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", size=(1920, 1080))
And then launch them with
Code:
show movie1 with fade
and hide
Code:
hide movie1 with fade
Or you can create custom screen for movies.
 
  • Like
Reactions: Leeuwenhoek

Leeuwenhoek

Newbie
Nov 21, 2018
23
25
Thanks for your quick reply! I assume this will allow the 1st video to move on automatically to the 2nd video by still being in the background so that I have access to the text window. And after the "hide movie1 with fade" I simply type "show movie2 with fade" and so on. I assume the code works for if a pic is in the next scene also. I may have been writing the wrong code.
I am either typing:

image car1 = Movie(play="videos/car1.webm",pos=(278,58), anchor=(0,0))
show car1

in which the video loops or I was typing this:

play movie "videos/car1.webm" noloop
show movie with fade

which doesn't loop the video but becomes stagnant and I have to click on the screen to move on to the next scene but it would be nice If the video automatically moved on to the next scene without clicking on the screen.

Here is an example of what I am trying to accomplish....

For Example: In one of the scenes 2 characters enters a vehicle and drives to a location. So I have a video like a pov view from the drivers perspective of you driving to a certain location. During the drive the 2 characters have a conversation but it ends way before the video ends. So you have a choice of clicking on the screen to move on to the next scene (whether it be another video or a pic) or sit back and enjoy the ride and the view until you get to the location. But when you sit back and enjoy the video .... and when it ends it either loops or if I type "no loop" it just ends without it moving on to the next scene unless I click on the screen.

But If I code the video in the foreground (in which I do not want) then it automatically moves on to the next scene when it ends but you have no access to the text window while the video is playing.

If this doesn't work .... Can I put some kind of timer timed with the duration of the video so when the timer counts down or up to the required duration it automatically ends the video to move on to the next scene? Most video scenes in my game is followed by a pic (scene).

Thanks!!! I do appreciate you taking the time out to reply me. I'll try what you suggested and see if that solves my video problem.
 
Last edited:

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,692
Try this way:

Python:
label your_label:
     image movie = Movie(size=(1280, 720), xpos=0, ypos=0, xanchor=0, yanchor=0)   ### You need this line just 1 time in your code

     play movie "movies/your_movie_1.webm" loop   ## Define movie1 with loop
     show movie with fade  ## show movie1
     "..."   ## dialogue (movie is playing in the backgroud)
     pause  ## pause with no dialogue (movie is playing in the backgroud too)
     "..."   ## more dialogue (movie is playing in the backgroud)
     hide movie with dissolve  ## Hide movie1

     play movie "movies/your_movie_2.webm"   ## Define movie2 without loop
     show movie with fade  ## show movie2
     pause 5.0   ### pause to see the video (can be forced is you want)

     scene your_next scene   ## The image you want to display after movie2 stop
     stop movie  ### stop any video to be able to continue with images
     "..." ## dialogue
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
Just on thing :

Python:
label your_label:
     image movie = Movie(size=(1280, 720), xpos=0, ypos=0, xanchor=0, yanchor=0)   ### You need this line just 1 time in your code
image is a statement that create it's own init context. Therefore it shouldn't be put in a label, but at level 0 of indentation :
Code:
image movie = Movie(size=(1280, 720), xpos=0, ypos=0, xanchor=0, yanchor=0) 

label your_label:
    [...]
It works like you wrote it, but it's one of those case that create an empty label then, following natural flow, continue with the anonymous block of code that follow. It's better to not take this (bad) habit, just in case the whole thing change in the future.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,692
Just on thing :



image is a statement that create it's own init context. Therefore it shouldn't be put in a label, but at level 0 of indentation :
Code:
image movie = Movie(size=(1280, 720), xpos=0, ypos=0, xanchor=0, yanchor=0)

label your_label:
    [...]
It works like you wrote it, but it's one of those case that create an empty label then, following natural flow, continue with the anonymous block of code that follow. It's better to not take this (bad) habit, just in case the whole thing change in the future.
Thanks! :D

I also forgot to use FullHD resolution :p
Python:
image movie = Movie(size=(1920, 1080), xpos=0, ypos=0, xanchor=0, yanchor=0)
 
  • Like
Reactions: Leeuwenhoek

Leeuwenhoek

Newbie
Nov 21, 2018
23
25
Thanks for your reply Mgomez0077 it worked! I had an extra line written in which didn't belong and it was stopping the video from automatically moving on. I had pretty well what you had written except for the "image movie .... " line in which I only used at the beginning of the project and when I wanted to resize a video for a specific scene.
 
Last edited:
  • Like
Reactions: Porcus Dev
Nov 21, 2020
21
9
Just use videos as backgrounds. So they will be as images for renpy and you can do with them all you want.
You just set the parameters, for example:
Code:
image movie1 = Movie(play="images/video/koshka_lenina.ogv", size=(1920, 1080))
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", size=(1920, 1080))
And then launch them with
Code:
show movie1 with fade
and hide
Code:
hide movie1 with fade
Or you can create custom screen for movies.
I am not able to solve loop problem my video is start again and again even I use hide and pause command
I just want to stop my video after he play once

Please help me as soon as possible
 

Higurashika

Well-Known Member
Nov 15, 2018
1,380
1,981
I want them to end my video at my last frame of my video
And what happens if u add hide?
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", size=(1920, 1080), loop=False)
hide movie2
Or you don't want to hide video? If so, you can't do what you want with renpy.
 
  • Like
Reactions: Kaushal Production
Nov 21, 2020
21
9
And what happens if u add hide?
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", size=(1920, 1080), loop=False)
hide movie2
Or you don't want to hide video? If so, you can't do what you want with renpy.
I am using hide with pause
If I am not using pause command my video is not even run due to hide command but I just want to end my video completely and stop at the last frame not in first frame
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
Higurashika got most of it, but missed one part.

There are two optional parameters to the Movie constructor:

"start_image" allows you to provide a static image that will be displayed while the movie is loading up in Ren'py. This should typically be the first frame of your video. Specifying this keeps people from seeing a brief "no image there" in your game if you display your movie with the "scene" instruction.

"image" allows you to provide a static image that will be displayed if the movie file doesn't exist but, more importantly, will also be displayed if the movie plays and then ends. Thus, if you use "loop=False", you almost always want to include the final frame.

So, your Movie declaration should probably look like:
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", loop=False, start_image="first_frame", image="last_frame")
Where "first_frame.jpg" is the first frame from your movie and "last_frame.jpg" is the last. (They don't have to be JPEG files - any file format supported by Ren'py is fine.)
 
Nov 21, 2020
21
9
Higurashika got most of it, but missed one part.

There are two optional parameters to the Movie constructor:

"start_image" allows you to provide a static image that will be displayed while the movie is loading up in Ren'py. This should typically be the first frame of your video. Specifying this keeps people from seeing a brief "no image there" in your game if you display your movie with the "scene" instruction.

"image" allows you to provide a static image that will be displayed if the movie file doesn't exist but, more importantly, will also be displayed if the movie plays and then ends. Thus, if you use "loop=False", you almost always want to include the final frame.

So, your Movie declaration should probably look like:
Code:
image movie2 = Movie(play="images/video/koshka_stalina.ogv", loop=False, start_image="first_frame", image="last_frame")
Where "first_frame.jpg" is the first frame from your movie and "last_frame.jpg" is the last. (They don't have to be JPEG files - any file format supported by Ren'py is fine.)
They say Image 'last_frame' not found
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
They say Image 'last_frame' not found
Check in the folder where you put the image corresponding to the last frame of your video, after creating it, if the name correspond to what you wrote in Ren'py. While you're there, and just in case, also check that the error don't come from the path to the image, if you haven't put it in the main "images" directory.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
They say Image 'last_frame' not found
"first_frame" and "last_frame" were just sample names for what you might have called the files. Also, as anne O'nymous points out, they will only be found that way if they're somewhere below the "game/images" folder. If they're not, then you have to give a path the way you're doing for the video file.
 

Deleted member 1610159

Newbie
Game Developer
Aug 26, 2019
55
34
Just on thing :



image is a statement that create it's own init context. Therefore it shouldn't be put in a label, but at level 0 of indentation :
Code:
image movie = Movie(size=(1280, 720), xpos=0, ypos=0, xanchor=0, yanchor=0)

label your_label:
    [...]
It works like you wrote it, but it's one of those case that create an empty label then, following natural flow, continue with the anonymous block of code that follow. It's better to not take this (bad) habit, just in case the whole thing change in the future.

I did everything you said. And everything worked out pretty well. but there is only problem.
during the dialoges when the videos is playing in the background it is all fine.
but when the dialogues end and the video is still playing. there is the black box of the dialogues still there.
Can anyone help me with that.
I want the displayable sceen clear and only showing video after the dialogues end.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,285
but when the dialogues end and the video is still playing. there is the black box of the dialogues still there.
Can anyone help me with that.
If I understood your problem correctly, the answer is in the " ". The best option being to put window auto somewhere in your "start" label. The the dial box will be automatically shown when there's a dialog line, and automatically hidden when there's nothing.

Edit:Corrected the link.
 
Last edited: