AudioStreamPlayer2D "Looping" parameter does not work in Web builds
Tested versions
v4.3.stable.official [77dcf97d8]
Bug observed in Microsoft Edge, Version 133.0.3065.69 (Official build) (64-bit)
Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 32.0.15.6636) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)
I know it's lazy, but I have not tested other Godot versions or other browsers...
System information
Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 32.0.15.6636) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)
Issue description
The behavior is that the AudioStreamPlayer2D only plays once when run in the browser, then never loops, despite looping properly when opened and run in Godot engine directly. Looping is set to true, as is Autoplay.
Running a Windows build also works as expected, with the music looping.
Steps to reproduce
I have however created a repository that replicates the issue, including a minimal game project, the Web build that reproduces the bug, and a Node Vite server to actually run the build in a browser (or use any static file server with HTTPS):
https://github.com/ericsartor/godot-music-loop-bug/tree/main
Minimal reproduction project (MRP)
https://github.com/ericsartor/godot-music-loop-bug/tree/main
Could you check if this bug still reproducible in Godot 4.4 rc 1?
Can confirm, still a problem in Godot 4.4 RC 1. Same scenario, loops properly in editor, loops properly in Windows build, does not loop at all in Web build.
FWIW, I have this in my notes: "mp3/ogg player looping flag override doesn’t seem to work; seems to work if manually edit import file" I.e. it seems the AudioStreamPlayer loop setting is ignored and it uses the import loop flag in web exports: https://github.com/ericsartor/godot-music-loop-bug/blob/main/music.mp3.import#L15
So, seemingly that explains why it works as expected in the Godot editor and in the Windows build, but not in the Web build? Is there perhaps a reason why someone might've made the behavior different?
Possibly related to the changes in 4.3 where web audio uses samples even for streams by default. Does the looping work if you change the "Playback Type" from "Default" to "Stream" so it forces stream even for web?
Interesting, that does work. So, setting the audio stream player to Stream explicitly instead of Default works in editor, on Web and on Windows. So...I guess the bug is related to how samples are handled on the Web platform? This means the documentation is wrong for this property. it says this:
"Default: The playback will be considered of the type declared at Audio > General > Default Playback Type."
In the sample project, that is set to "Stream". So apparently that is being ignored when building for Web? And either way, defaulting to Sample in any case would be kind of odd, since there are caveats like lack of support for AudioEffects, meaning even if it did loop, I'd suddenly lose my AudioEffects without having opted in to that behavior explicitly?
Maybe not super clear, but for web it uses audio/general/default_playback_type.web which defaults to sample. There's a blog post why it's using samples on the web by default. See https://godotengine.org/article/progress-report-web-export-in-4-3/.
Ah, I totally missed that, thanks for clarifying. So, after having read that article, I take it that Samples are the future for how audio gets handled on the Web platform. So, I suppose that means, as far as this bug report is concerned, that the bug here is "looping audio using Sample playback doesn't seem to work"?
@ericsartor if you need a solution until they solve this problem, this plugin here works loop for web: https://godotengine.org/asset-library/asset/3811
@Saulo-de-Souza This is an english channel, please keep all messages here in english. If you don't know english you can use a software like google translator for help.
Esse canal é exclusivamente em inglês, por favor mantenha todas suas mensagens em inglês por aqui. Você pode usar o google tradutor caso não saiba escrever em inglês.