[SOLVED] Audio Controls in Movies

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
galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

[SOLVED] Audio Controls in Movies

#1 Post by galadain »

I'm playing movies playing movies by first defining it like this:

Code: Select all

image fight_scn1 = Movie(play="fight_scn1.webm")
And then calling the movie with:

Code: Select all

scene fight_scn1
I need the movie to play while the user is clicking through text. This code works perfect for what I want. The problem is the standard volume options don't work for the movie played this way. Users can't control or mute the volume. How do I fix this?
Last edited by galadain on Sat Jun 19, 2021 12:04 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#2 Post by Alex »

Try to make a slider for 'movie' channel volume or set the other channel for Movie displayable - https://www.renpy.org/doc/html/movie.html#Movie

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#3 Post by galadain »

Okay. So I tried to make the following changes to control the movie playback sound with the normal Ren'Py voice channel controls.

Code: Select all

image fight_scn1 = Movie(channel=voice.channel, play="fight_scn1.webm")

Code: Select all

image fight_scn1 = Movie(channel=voice, play="fight_scn1.webm")
Neither option works. Please advise.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#4 Post by Alex »

Try it like

Code: Select all

init python:
    renpy.music.register_channel("my_movie_channel", mixer="my_mixer", loop=True, movie=True)
    
image my_movie = Movie(channel="my_movie_channel", play="images/Clips/oa4_launch.webm")
    
# The game starts here.
label start:
    "..."
    show my_movie at truecenter
    "?!"
And bar in preferences screen

Code: Select all

                    label _("My_movie Volume")

                    hbox:
                        bar value MixerValue("my_mixer")
                        textbutton "0.5" action Function(preferences.set_volume,"my_mixer", 0.5)
                        textbutton "1.0" action Function(preferences.set_volume,"my_mixer", 1.0)

https://www.renpy.org/doc/html/audio.ht ... er_channel
https://www.renpy.org/doc/html/screen_a ... MixerValue
https://www.renpy.org/doc/html/screen_a ... l#Function
https://www.renpy.org/doc/html/preferen ... set_volume

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#5 Post by galadain »

Sorry I didn't reply sooner. Is there a way to accomplish this using the existing audio channels/controls instead of creating a new one?

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#6 Post by Alex »

No, I'm afraid, 'cause audio channels doesn't have 'movie=True' property. Besides, you wanted to control the volume of the sound in video. So, make a channel and mixer and change their volume as you need separately from music/sound.

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#7 Post by galadain »

Here's my code:

Preferences

Code: Select all

            label _("My_movie Volume")

            hbox:
                bar value MixerValue("my_mixer")
                textbutton "0.5" action Function(preferences.set_volume,"my_mixer", 0.5)
                textbutton "1.0" action Function(preferences.set_volume,"my_mixer", 1.0)
Script

Code: Select all

$ renpy.music.register_channel("my_movie_channel", mixer="my_mixer", loop=True, movie=True)

image mov1 = Movie(channel="my_movie_channel", play="mov1.webm")

# The game starts here.

label start:

scene mov1
with fade
No errors and the movie still plays. Still no control over volume even with the new bar.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#8 Post by Alex »

Hm, that's strange - it worked for me with starship launching video from tutorial game. Could you try different videos?

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#9 Post by galadain »

Tried it with three different movies. Still no audio control with new or existing channels

Code: Select all

image mov1 = Movie(channel="my_movie_channel", play="mov1.webm")
image mov2 = Movie(channel="my_movie_channel", play="mov2.webm")
image mov3 = Movie(channel="my_movie_channel", play="mov3.webm")

Code: Select all

scene mov1
with fade

scene mov2
with fade

scene mov3
with fade

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#10 Post by Alex »

Still working for me... So, you hear sound but unable to change its volume? Try the new project to test just this code.

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#11 Post by galadain »

Correct. I can hear the sound as if I was playing the .webm in a normal Windows media player. However, none of the Ren'py volume options, including the custom one you suggested I create, control the volume for the movie.

I'm curious I've I'm putting this code in the correct place.

Code: Select all

            label _("My_movie Volume")

            hbox:
                bar value MixerValue("my_mixer")
                textbutton "0.5" action Function(preferences.set_volume,"my_mixer", 0.5)
                textbutton "1.0" action Function(preferences.set_volume,"my_mixer", 1.0)
Which script file and under what section should that code be in?

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Audio Controls in Movies

#12 Post by Alex »

galadain wrote: Fri Jun 18, 2021 9:54 pm ...

Code: Select all

            label _("My_movie Volume")

            hbox:
                bar value MixerValue("my_mixer")
                textbutton "0.5" action Function(preferences.set_volume,"my_mixer", 0.5)
                textbutton "1.0" action Function(preferences.set_volume,"my_mixer", 1.0)
Which script file and under what section should that code be in?
This should be a part of preferences screen - slider for volume control (like it already made for music, sound and voice).

Try this project - run the game, open preferences and move the slider.
test_video_volume.rar
(606.74 KiB) Downloaded 28 times

galadain
Regular
Posts: 31
Joined: Wed Sep 09, 2020 4:24 pm
Contact:

Re: Audio Controls in Movies

#13 Post by galadain »

Changed my code to make it identical to yours and it's working now. Thanks!

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne