Autostart music when the game is loaded (web build)

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
renpynoob
Newbie
Posts: 10
Joined: Wed Jul 27, 2022 3:56 pm
Contact:

Autostart music when the game is loaded (web build)

#1 Post by renpynoob »

How can I make music start automatically after loading?

Currently, the music only starts after any user click.

I've added

Code: Select all

define config.main_menu_music = "audio/menu.mp3"
to options.rpy and the music auto starts on PC, but that doesn't work for a web build.

User avatar
gacha_kareyka
Newbie
Posts: 4
Joined: Mon Aug 26, 2024 4:36 pm
Projects: Winter Gacha: Episode 1(stage Development)
Deviantart: gacha-koreika
Discord: ezhik_s_golubimivolosami

Re: Autostart music when the game is loaded (web build)

#2 Post by gacha_kareyka »

I realise this is an old topic, but I don't care.

Try using renpy.music.play for the web version only.

Code: Select all

if renpy.variant("web"):
	renpy.music.play("*your file music*", channel = "music", loop = true)
I hope I've done something useful... :o

renpynoob
Newbie
Posts: 10
Joined: Wed Jul 27, 2022 3:56 pm
Contact:

Re: Autostart music when the game is loaded (web build)

#3 Post by renpynoob »

gacha_kareyka wrote: Wed Aug 28, 2024 3:11 pm I realise this is an old topic, but I don't care.

Try using renpy.music.play for the web version only.

Code: Select all

if renpy.variant("web"):
	renpy.music.play("*your file music*", channel = "music", loop = true)
I hope I've done something useful... :o
Have you tried this yourself? I don't think there is a solution because browsers prevent any sounds before user actions. So I added a splash page before the main screen where the player has to click to continue.

Post Reply

Who is online

Users browsing this forum: No registered users