Music not playing at beginning of scene. Please help!


#1

Okay, so I started working on a game, and made a test room to test the character. I also put music in this scene.
However, I did this on an earlier version (Maybe GD5 V54). When I decided to upgrade to the latest version (GD5 V61 as of now), the music suddenly does not work when the scene loads.
My code is:
“At the Beginning of the Scene: Play Music on a Channel.” (That is all that there is)
Unfortunately, it doesn’t work anymore!
Even more strange, when I open the debugger and pause the preview, the music DOES play. When I unpause the scene, the music stops! I want it to do the opposite!
I also tried this with a different music track. Same results… :frowning:
I have no idea why it does this. Is this a bug that was introduced in GD5 V61, or am I just a moron who is clearly doing something wrong?
Any help is appreciated. Thanks.


#2

Anybody? Please?? :cry:


#3

I can not reproduce it, music play fine at the beginning of the scene here :confused:
Opened an old project in v61 and works for me.

Did you try to create a new empty project where the ONLY thing you do is play a music at the beginning?
I would recommend to try it and if it doesn’t work, post it here with a free music from the internet so we can have a look.


#4

Thank you for your reply mate. :smiley:
Now, I did what you said. I made a new project, and put absolutely no events other that one one that plays the music. Strangely, it doesn’t play. Here is the file. Am I doing something incorrectly?? Thanks in advance.

Edit: Um, can you help me quick? The website is not letting me upload the file…


#5

Can’t you upload it to a file sharing platform then?
Like this:
uploadfiles.io/

Or Google Drive, DropBox, OneDrive…etc and share a link to download here.

Not sure why it doesn’t let you upload it. I think there is a size limit, in case the music is huge, include something smaller it doesn’t need to be long. Or just share your project file and then I can drop something in…


#6

Should I post the file in the link you provided? Otherwise, I can try Google Drive.


#7

I have uploaded the file online. It can be found here: ufile.io/7ws4s
The music isn’t mine BTW, it is Nintendo’s from SMO. I’m just using it for testing.

Also, I upgraded to version 62 recently. Same results.


#8

By chance it works if instead the action to play music you use the action to play sound?

If so it’s a very tricky bug that I haven’t been able to catch, and totally forgot it, can you add an issue on GitHub please?, if you add the example there, better, also information like the browser and OS is useful :slight_smile:


#9

Actually the problem is, in HTML5 audio is not allowed to play (not sure why) before the user interact with the page.
If you click the game window, the music starts playing.
Not sure if it’s a bug. I believe browsers do this by purpose because of the ads maybe or security reasons?

Anyway, to work around, always make sure the user does interact with the screen when the game starts like add a play button that needs to be clicked or something in one scene and then go to the next scene where the music is going to start playing.


#10

You know, in the latest version of GDevelop (V62) there is a new example called “Music on Mobile” that says that the music has to be played as a sound instead of a music file. I’m not making a mobile game, but sounds work just fine. I think this could actually work in the meantime before the bug is fixed! Thanks mate!

I also reported the bug on Github if that helps.


#11

It’s top secret… don’t tell anybody… come here… closer: The code to play sounds and musics is exactly the same, they’re separated for compatibility with old projects :laughing:

Aside that, the code is exactly the same but the music doesn’t work, as said before this bug is a mystery, there must be a difference somewhere but no luck for me :confused:


#12

If you check the console the browser gives a brief explanation of failed to play audio because the user did not interact with the page and provide a link to google to find more details about cause:
developers.google.com/web/updat … cy-changes

Maybe, you guys are looking at this the wrong way, the real bug here is that the sound is playing :smiling_imp:
The fact the music does not play is a “feature” and not a bug :laughing:


#13

I was aware of the error code, yes, but the code is the same for sound and it works, that’s what killed me the first time I tried to fix it :confused:

In the meantime (or from now on) you can add a dummy scene with a single button or even just a message “Press to start”, done, your music will work from now :slight_smile: