Stop sound in main menu(Solved)

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
Pandar
Newbie
Posts: 24
Joined: Sun Dec 08, 2019 1:29 am
Contact:

Stop sound in main menu(Solved)

#1 Post by Pandar »

Hi! I'm new to ren'py and a total noob.
I added some sounds in my script but when I return to the main menu, the sound doesn't stop. Do I have to add "stop sound" somewhere?
Last edited by Pandar on Mon Dec 16, 2019 4:44 pm, edited 1 time in total.

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Stop sound in main menu

#2 Post by isobellesophia »

Can you show the code so it can be specific?
I am a friendly user, please respect and have a good day.


Image

Image


Pandar
Newbie
Posts: 24
Joined: Sun Dec 08, 2019 1:29 am
Contact:

Re: Stop sound in main menu

#3 Post by Pandar »

isobellesophia wrote: Wed Dec 11, 2019 11:16 am Can you show the code so it can be specific?
I'm using "The question" novel to practice. I simply added "play sound "sounds/rain.mp3"" and then "stop sound", but when I return the main menu the sound is still there.

Code: Select all

# Declare characters used by this game.
define s = Character(_("Sylvie"), color="#c8ffc8")
define m = Character(_("Me"), color="#c8c8ff")

# This is a variable that is True if you've compared a VN to a book, and False
# otherwise.
default book = False


# The game starts here.
label start:

# Start by playing some music.
play music "illurock.opus"

scene bg lecturehall
with fade

"It's only when I hear the sounds of shuffling feet and supplies being put away that I realize that the lecture's over."

"Professor Eileen's lectures are usually interesting, but today I just couldn't concentrate on it."

play sound "sounds/rain.mp3"

"I've had a lot of other thoughts on my mind...thoughts that culminate in a question."

stop sound

"It's a question that I've been meaning to ask a certain someone."

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Stop sound in main menu

#4 Post by isobellesophia »

How about this? Replace the main menu textbutton into this one.

Code: Select all

textbutton _("Main Menu") action [Stop("sfx"), Start()]
Sorry for the late reply.
I am a friendly user, please respect and have a good day.


Image

Image


Pandar
Newbie
Posts: 24
Joined: Sun Dec 08, 2019 1:29 am
Contact:

Re: Stop sound in main menu

#5 Post by Pandar »

isobellesophia wrote: Wed Dec 11, 2019 12:11 pm How about this? Replace the main menu textbutton into this one.

Code: Select all

textbutton _("Main Menu") action [Stop("sfx"), Start()]
Sorry for the late reply.
In the navigation screen? I copied it like that and it doesn't work.

Code: Select all

screen navigation():

    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.5

        spacing gui.navigation_spacing

        if main_menu:

            textbutton _("Start") action Start()

        else:

            textbutton _("History") action ShowMenu("history")

            textbutton _("Save") action ShowMenu("save")

        textbutton _("Load") action ShowMenu("load")

        textbutton _("Preferences") action ShowMenu("preferences")

        if _in_replay:

            textbutton _("End Replay") action EndReplay(confirm=True)

        elif not main_menu:

            textbutton _("Main Menu") action [Stop("sfx"), Start()]

        textbutton _("About") action ShowMenu("about")

        if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):

            ## Help isn't necessary or relevant to mobile devices.
            textbutton _("Help") action ShowMenu("help")

        if renpy.variant("pc"):

            ## The quit button is banned on iOS and unnecessary on Android and Web.
            textbutton _("Quit") action Quit(confirm=not main_menu)

Do I have to rename "sfx" to something else?

Sorry for bad english

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: Stop sound in main menu

#6 Post by isobellesophia »

Actually, that is just an example of the name of your sound. Replace that with your rain sound instead.
I am a friendly user, please respect and have a good day.


Image

Image


Pandar
Newbie
Posts: 24
Joined: Sun Dec 08, 2019 1:29 am
Contact:

Re: Stop sound in main menu

#7 Post by Pandar »

isobellesophia wrote: Wed Dec 11, 2019 12:36 pm Actually, that is just an example of the name of your sound. Replace that with your rain sound instead.
Ok sorry ahah I got this error :

While running game code:
File "renpy/common/00gamemenu.rpy", line 173, in script
$ ui.interact()
File "renpy/common/00gamemenu.rpy", line 173, in <module>
$ ui.interact()
File "renpy/common/00action_audio.rpy", line 127, in __call__
renpy.music.stop(channel=self.channel, **self.kwargs)
Exception: Audio channel u'sounds/rain.mp3' is unknown.



I can hear the rain sound in-game, so the file is in the right folder.

EDIT: solved, I created a new sfx channel.
Thanks for the replies.

User avatar
zankizuna
Veteran
Posts: 416
Joined: Fri May 04, 2012 2:20 am
Completed: Monochrome Valentine
Projects: Softwar
Deviantart: raseru09
itch: ZanKizuna
Location: Manilaaaaaaaa
Contact:

Re: Stop sound in main menu

#8 Post by zankizuna »

add this to your screen

Code: Select all

screen navigation():
    on 'show' action Stop('sfx')

or

Code: Select all

screen navigation():
    on 'show' action Stop('sound')

Post Reply

Who is online

Users browsing this forum: No registered users