Video (file) behind main menu

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
cementoliquido
Newbie
Posts: 12
Joined: Wed Sep 04, 2013 10:02 am
Contact:

Video (file) behind main menu

#1 Post by cementoliquido »

Hello everyone ! I'm here again because I would like to ask a question.

I need to display a video (like an .avi file) behind the main menu screen. I mean, the video should play and repeat, while the buttons (such as new game and options) should remain clickable as usual, but I have no idea what to do. I already tried changing the background and putting an ATL animations, but it's not what me and my friend are looking for.
I hope you guys can help, thanks in advance ! :D

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Video (file) behind main menu

#2 Post by PyTom »

It's doable.

You have to add to the start of the main menu screen the lines

Code: Select all

screen main_menu:
    add Movie(size=(800, 600))
    on "show" action Play("movie", "foo.ogv")
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")

    ...
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Video (file) behind main menu

#3 Post by Elmiwisa »

PyTom wrote:It's doable.

You have to add to the start of the main menu screen the lines

Code: Select all

screen main_menu:
    add Movie(size=(800, 600))
    on "show" action Play("movie", "foo.ogv")
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")

    ...
A few details I would like to point out.
1. add lines need to be sandwiched between the background window and the button box, otherwise either the movie get obscured or the button are obscured.
2. on "replace" is needed too otherwise getting into a submenu and return will make the movie disappear.
3. This have problem with the close window button for some reason. Specifically, if your menu is like this, weird thing happen when you try to close window using the X.

cementoliquido
Newbie
Posts: 12
Joined: Wed Sep 04, 2013 10:02 am
Contact:

Re: Video (file) behind main menu

#4 Post by cementoliquido »

Thank you very much, these lines work perfectly :D
another question: To have the video loop continuosly, what should I have to do ?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Video (file) behind main menu

#5 Post by PyTom »

I think it's:

Play("movie", "foo.ogv", loop=True)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

cementoliquido
Newbie
Posts: 12
Joined: Wed Sep 04, 2013 10:02 am
Contact:

Re: Video (file) behind main menu

#6 Post by cementoliquido »

I realized it just after I posted, and it worked by writing "loop=1" but I guess it's the same thing... Thank you very much !

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Video (file) behind main menu

#7 Post by Elmiwisa »

cementoliquido wrote:Thank you very much, these lines work perfectly :D
another question: To have the video loop continuosly, what should I have to do ?
Wait, are you saying that you managed to fix the close window problem? How did you do it?

cementoliquido
Newbie
Posts: 12
Joined: Wed Sep 04, 2013 10:02 am
Contact:

Re: Video (file) behind main menu

#8 Post by cementoliquido »

Sorry, I didn't answer before because of a connection problem

Anyway, I didn't actually solve this "close window" problem, in fact, when I want to close the window, only the menu disappears while the video keeps playing... I tried something but I didn't get anywhere

I don't know if this can be done properly.. Do you have any ideas ?
Thanks for your help, I really appreciate it

User avatar
Zelika
Newbie
Posts: 7
Joined: Mon Nov 04, 2013 11:01 pm
Projects: Blind
IRC Nick: ValerieXarichi
Location: Philippines
Contact:

Re: Video (file) behind main menu

#9 Post by Zelika »

I'm a newbie at Ren'Py coding and I was wondering that

I followed the instructions in this topic, (even changed the foo.ogv) but when I tested it out, my main menu is still the same before (▰˘︹˘▰)

can anyone help please?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Video (file) behind main menu

#10 Post by xavimat »

@Zelika: Can you show your code of the screen main_menu?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Zelika
Newbie
Posts: 7
Joined: Mon Nov 04, 2013 11:01 pm
Projects: Blind
IRC Nick: ValerieXarichi
Location: Philippines
Contact:

Re: Video (file) behind main menu

#11 Post by Zelika »

xavimat wrote:@Zelika: Can you show your code of the screen main_menu?
Sure.

Code: Select all

screen main_menu:
    add Movie(size=(2184, 1900))
    on "show" action Play("movie", "Opening/Hello Laughter.mp4")
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")

    # This ensures that any other menu screen is replaced.
    tag menu

    # The background of the main menu.
    window:
        style "mm_root"

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .5
        yalign .5

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Options") action ShowMenu("preferences")
        textbutton _("Quit") action Quit(confirm=False)

init -2 python:

    # Make all the main menu buttons be the same size.
    style.mm_button.size_group = "mm"
Image

い あm すch あn おたく。。。
い ぃけ いt!

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Video (file) behind main menu

#12 Post by xavimat »

Elmiwisa has pointed out that:
Elmiwisa wrote:1. add lines need to be sandwiched between the background window and the button box, otherwise either the movie get obscured or the button are obscured.
I have'nt checked but, maybe you can put your movie after the "window":

Code: Select all

screen main_menu:
    on "show" action Play("movie", "Opening/Hello Laughter.mp4")
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")

    # This ensures that any other menu screen is replaced.
    tag menu

    # The background of the main menu.
    window:
        style "mm_root"

    add Movie(size=(2184, 1900))

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .5
        yalign .5

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Options") action ShowMenu("preferences")
        textbutton _("Quit") action Quit(confirm=False)
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Zelika
Newbie
Posts: 7
Joined: Mon Nov 04, 2013 11:01 pm
Projects: Blind
IRC Nick: ValerieXarichi
Location: Philippines
Contact:

Re: Video (file) behind main menu

#13 Post by Zelika »

xavimat wrote:Elmiwisa has pointed out that:
Elmiwisa wrote:1. add lines need to be sandwiched between the background window and the button box, otherwise either the movie get obscured or the button are obscured.
I have'nt checked but, maybe you can put your movie after the "window":

Code: Select all

screen main_menu:
    on "show" action Play("movie", "Opening/Hello Laughter.mp4")
    on "hide" action Stop("movie")
    on "replaced" action Stop("movie")

    # This ensures that any other menu screen is replaced.
    tag menu

    # The background of the main menu.
    window:
        style "mm_root"

    add Movie(size=(2184, 1900))

    # The main menu buttons.
    frame:
        style_group "mm"
        xalign .5
        yalign .5

        has vbox

        textbutton _("Start Game") action Start()
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Options") action ShowMenu("preferences")
        textbutton _("Quit") action Quit(confirm=False)
I tried that, but my menu still hasn't changed.... (sorry for the late reply)
Image

い あm すch あn おたく。。。
い ぃけ いt!

User avatar
Aurelius
Newbie
Posts: 20
Joined: Fri Jun 06, 2014 6:56 pm
Projects: Secrets of the Ark, Degrees of Freedom
Organization: Bleau Eye Entertainment
Location: United States
Contact:

Re: Video (file) behind main menu

#14 Post by Aurelius »

Thank you cementoliquido for asking that question and thank you PyTom for answering now I have fully functionable animated backgrounds for my main menu :D

bargencat
Newbie
Posts: 1
Joined: Mon Jul 16, 2018 4:22 am
Contact:

Re: Video (file) behind main menu

#15 Post by bargencat »

I have a movie background that is made to be in sync with an audio. If I use the code Pytom suggested then I get the synced audio-video just once. Clicking a menu button and then returning to menu breaks the sync. The audio doesn't break it's loop but the video does.

How do I make it so that the video doesn't break it's loop regardless of me clicking other menu buttons and then going back to main menu again?

This is the code I'm using

Code: Select all

screen main_menu():

    # This ensures that any other menu screen is replaced.
    tag menu
    
    add Movie(size=(1920, 1080))
    on "show" action Play("movie", "gui/main_menu.ogv", loop=True)
    on "hide" action Stop("movie")
    on "replace" action Play("movie", "gui/main_menu.ogv", loop=True)
    on "replaced" action Stop("movie")

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot