EDIT: I forgot to insert a quote and it works also with a playlist but will reset every time you visited the video gallery
umineko wrote: ↑Tue Oct 25, 2022 4:55 am
Regarding your solution, it works well, but I'm not able to get the music playing again once the player leaves the screen.
Hi there, we should better not touch the 00gallery.rpy because it's also doable with normal screens.
Here's my solution wich works under the following conditions:
1. I assume that you
play only one music file and use the defined Ren'Py Menus/Screens.
2. You want to hear the music during the whole game, also in the menus.
3. You want to turn it off in the video gallery and play it again when you leave the menu.
My procedure is as follows: We write a function that determines whether music is played and if not then plays it. We call this function in the navigation bar of the menu, so we make sure that it is turned on again as soon as the video gallery is left.
This function goes into your script.rpy
Code: Select all
# The script of the game goes in this file.
# This function will check if a music is played and turn it on if not.
init python:
def sound_check():
if renpy.music.is_playing(channel=u'music')== False:
renpy.music.play(config.main_menu_music, fadein=0.5, loop=True) # no need to edit the audio files twice. we just use the var
return
# Set an audio file that will be played while
# the player is at the main menu. This file will continue playing into the
# game, until it is stopped or another file is played.
define config.main_menu_music = "audio/ost.mp3" ### a single audio file
# define config.main_menu_music = ["audio/ost.mp3","audio/score.wav","disco.mp3"] ### a playlist
Next step is to insert the function call in the screens.rpy
We use the screen_navigation(): You'll find it in Line 288
Code: Select all
timer 0.01 repeat False action Function(sound_check)
It should look like this:
Code: Select all
screen navigation():
timer 0.01 repeat False action Function(sound_check)
vbox:
style_prefix "navigation"
xpos gui.navigation_xpos
...
That's it.
Hope it helps!
p.s. leave your screen video_gallery like before.
Code: Select all
screen video_gallery():
timer 0.01 repeat False action Function (renpy.music.stop, fadeout= 0.5) # fadeout music on channel music
tag menu
## This use statement includes the extras_menu screen inside this one.
use extras_menu("Videos"):
vpgrid:
cols 2
spacing 23
...