-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Play Music on a Channel" action not working like it used to. #878
Comments
+1, i know this bug ! But it's strange because its working on local export. |
Yes, I press Esc to restart scene and as soon as you do that it's working, no delay, odd?! |
This is because of a Chrome limitation (which is running GD and previews) that prevent any sound from running if you've not interacted first with the window containing the game. (it's a "feature" of Chrome) So a sound starting at the beginning of the game won't work. But a sound starting later, or even when you go back to the scene, will work. |
I understand that, but does it explain why sound command works, but music doesn't? I just tested and the same mp3 music file doesn't play until scene refresh, but it works fine if played using the play sound command? |
Oh not sure about this, will have to investigate what is the difference then! |
I did not export the project, to answer KinkGD's question. Does it work on export? |
Is this the same issue as #556? |
Answer is that Music forces HTML5 audio and Sound uses Web Audio by default. I changed this line (237) in howler-sound-manager.js and then Sound and Music behaved the same, a delay before playing sound as Web Audio has to load the whole sound, whereas HTML5 Sound plays while loading. Not sure how you might change it to make it work any better, HTML5 playback is fine after a click or touch! |
Super interesting, I never realized this was related to this. |
Actually, updating Howler.js sound library might be enough. I see commits related to audio locking: https://github.com/goldfire/howler.js/commits/master Could maybe be as simple as replacing howler.min.js file by the new one. We're on v2.0.7, while 2.1.1 is available. There is a card for it: https://trello.com/c/lV2jnvBq/163-update-howlerjs-to-latest-version |
I'll have a go at updating howler.js as I'm familiar with the issues, is this purely js or was it converted from GD4? Do I just need to check for any API changes, update the js file and test? |
This is purely JS.
Exactly :) If there are some API changes, any changes should be in howler-sound-manager.js (so should be pretty limited - the rest of the engine is agnostic toward the sound manager implementation). Updating Howler could also bring better compatibility with Safari 12, so would be great to do! :) |
Looks like this was last updated in Feb. I'm seeing a bunch of new folks on the discord asking about this. My understanding is howler is now updated, but this issue still persists (play music/play music on channel do not play any files, while play sound/play sound on channel can play the same files fine). Is there any other testing I can assist with on this that might help pinpoint it, or is there still a path forwards towards resolution being worked on? |
This is the browser working as designed. If you play as Music gd forces HTML5 audio, whereas play as Sound uses Web Audio. See my post 3 months ago for more detail on the differences 😊 Maybe we need to change the ide and doc to say Web Audio instead of Sound, and HTML stream instead of Music. 🤔 |
Thanks for the heads up, Zatsme. Just to check, would that impact Game Preview in addition to exported to HTML? Because using Play Music also doesn't work when previewing a game in most cases. |
ok, hopefully to clear it up:- If you use play sound: This uses the older Web Audio which cannot stream files. Soundfile will load and play as soon as it's completely loaded, almost instantly for short effects, longer for music depending on filesize!! If you use play music: This uses HTML5 Audio which can stream files. Soundfile can start to play as it's being loaded (stream) which is a better/newer system.
😖 |
@zatsme is right. No way to work around this (other than loading/intro screen with a click/touch to start). Any idea to make this clearer in GDevelop is welcome! |
@4ian @zatsme That said, I still want to reconfirm: Does the above explain why the game preview doesn't work with Play Music either? Is preview mode still held by the same limitations as playing a hosted exported HTML game in a browser? |
Yes, because preview is running inside (basically) Chrome which has this limitation built in :( |
Thanks for the heads up and clarification. Makes unfortunate sense to me. |
Since this is still open, I'm adding feedback from a confused user:
So the warning has been understood as "music will only be played when user has interacted with the game". |
Hello guys, I checked it after 3 hours testing, compilations and publishing and it works:
All of this I checked in build application - any kind, publish for website (Liluo.io) and... it works :) Not sure every Android but I checked 8.0, 8.1, 9.0 and 11 it is okay too. Very nice option to do any video especially for this problem if free software DaVinci Resolve 17, my recommendation guys :) Video settings for the smallest thing (you can scale it on the scene later), and very small file with music: My logo with music its just 2MB and fade-in/out only. Best regards to all |
Hello @Orghal, Normally you shouldn't be posting in a closed issue, especially one that has been closed for ~3 years. For the issue in this thread, the recommended solution is to use the "Play a sound on a channel" events instead of the "Play a music on a channel". Keep in mind "Play a sound" means "Play a sound file" not "Play a sound effect" I'm glad you found another solution that works for you, but keep in mind it isn't needed to avoid this issue with audio files not starting with the game before it is interacted with. |
The action "Play Music on a Channel" does not play your music file. if one was to have music play at the beginning of a scene, no music will play in the preview.
To Reproduce
Steps to reproduce the behavior:
Using Windows
In the meantime, there is a workaround to this problem. If you play the music file as a SOUND instead, it WILL play, like in mobile.
The text was updated successfully, but these errors were encountered: