4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
9.38k stars 802 forks source link

Audio doesn't work in iOS 12 and Safari 12.0 for Mac #657

Closed magiccccat closed 5 years ago

magiccccat commented 5 years ago

Describe the bug

After upgrading the iPhone to iOS 12 and the Mac to Safari 12.0 in September 2018, the sound in any game exported for web won't play in those browsers. However, if using Chrome for Mac (69.0.3497.100) to open the game, the sound works normally.

To Reproduce

Steps to reproduce the behavior:

1, Create a project from any demo game 2, Use Network Preview to preview 3, Open the game in the following browsers: -Safari 12.0 (13606.2.11) -iOS 12.0 (16A366)

Other details

Tried editor: -GDevelop 5.0.0-beta52 for Mac -GDevelop 5.0.0-beta51 for Mac Both reproduce the same result.

4ian commented 5 years ago

What is the audio file format? mp3, wav, ogg?

magiccccat commented 5 years ago

It is a wav. However, I found the solution already. It is a problem of howler soundmanager in Safari 12 upgrade. You can find it here https://github.com/goldfire/howler.js/pull/1047/files

4ian commented 5 years ago

Nice! Howler.js would then need an upgrade in the game engine :)

Jose-Moreno commented 5 years ago

@4ian Have you guys updated howler ever since? I've seen some people on discord recently complaining they are not getting sound on iOS after export however I'm not sure if it's related to this particular problem or if it is something else (i.e PhoneGap).

4ian commented 5 years ago

I had not, there was no official release at this time with the fix, but this is the case since then: https://github.com/goldfire/howler.js/releases

Created a task here: https://trello.com/c/thaeM4Sc/337-update-howlerjs-to-latest-version-v212-notably-to-get-safari-ios-fixes-and-auto-unlock-of-audio-on-mobile :)

4ian commented 5 years ago

Mmm no I was mistaken, turns out we're already using version 2.1.1. I updated to version 2.1.2 but not sure this will improve something. I think things might be due to browser restrictions.

4ian commented 5 years ago

So yeah this might be due to browser restriction on audio (this is on Chrome too on latest versions). To work around this, you must ensure that the player touched the screen or interacted with the mouse (click) or keyboard before starting music/sounds. It will work well after that.

Jose-Moreno commented 5 years ago

@4ian I was reading the exact same issues on the howler repo afterward. I don't have an iOS or mac device, but will let the other users know so they can test this. Thanks for all the hard work! :smile:

magiccccat commented 5 years ago

I am using the latest GDevelop. In iOS and macOS, my new game works well. Although a bit weird is that safari requires users tap twice before play audios, not sure why or whether it is just my phone. However I don’t think it is an issue on the gamer experience comparing with tap-once requirement.

4ian commented 5 years ago

Great! So seems like updating Howler to the very latest version was a good idea :) Glad that it works :)