selimanac / defold-modplayer

MOD/XM Module Player for Defold Engine
https://selimanac.github.io/
12 stars 1 forks source link

HTML5 build autoplay policy #7

Open HornyCrusader opened 9 months ago

HornyCrusader commented 9 months ago

Hello. Any way to prevent this from happening? While trying to play HTML5 build in any browser there is Autoplay policy warnings that preventing from using AudioContext and play music. AutoPlay

In example https://selimanac.itch.io/mod-player-demo-nanowar it plays fine coz user need to click play and only after that app begin to initiate. But for example on Yandex.games there is no preinitialization stage - uploaded example of nanowar for testing (https://yandex.ru/games/app/294759?draft=true&lang=ru).

What to do and how to fix? Thanks.

selimanac commented 9 months ago

Difference between the sites is not about the interaction, but because of the iframe permission. As you can see, itch.io has autoplay and fullscreen permissions:

Screenshot 2024-03-02 at 22 28 18

But Yandex doesn't:

Screenshot 2024-03-02 at 22 31 14

If you have control over iframe(maybe somewhere on Yandex page where you upload the files) html code, you can add 'allow="autoplay"' which is mentioned here: https://developer.chrome.com/blog/autoplay/#iframe_delegation Also fullscreen is not working on Yandex because of the same reason.

HornyCrusader commented 9 months ago

The most interesting thing is that through -emrun on the local machine, the application behavior is exactly the same. Tested on two browsers Brave, Firefox. I use a Linux machine with Arch. The build from the editor works fine. The bundle for HTML5 does not. image image

Tested on every project there is with modplayer. Even https://github.com/selimanac/modplayer-html5-example same behavior. Interesting... Maybe there some magic need to do with dmloader.js?