goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24.01k stars 2.23k forks source link

howler 2.0 and auto unlock audio on mobile #505

Closed JenGL closed 5 years ago

JenGL commented 8 years ago

If you use html5: true in howler 2.0 the auto-unlock audio with user gesture doesn't work.

goldfire commented 8 years ago

It seems to be working for me. Can you provide a sample and specify a mobile platform/browser?

JenGL commented 8 years ago

https://jsfiddle.net/vsm3rhr2/1/

as you can see after the tap on the box the first audio is reproduced but not the second. It requires another tap ! The problem may be that for every html5 sound you create obvious a new Audio(); object that can't be unlocked with a previous tap

goldfire commented 8 years ago

I haven't been able to find a workaround for this so far. The issue is being tracked within Chromium here: https://bugs.chromium.org/p/chromium/issues/detail?id=178297. If anyone can find a workaround I'll be happy to include it.

JenGL commented 8 years ago

I have no time to implement this now, but you should create more audio element in the initialization of the lib and on the first touchevent unlock these element all together. Create an audioPoll where you can ask for an audio element that is free and use that poll instead of creating new Audio allover the code. The audio element will be inserted in the poll on the end of the reproduction.

This is working for me (I'm implementing this directly with audio tag without Howler atm)

JenGL commented 8 years ago

I tryed a draft implementation of what i was tryng to explain in the last comment: this is the code: (based on 2.0.0-beta12) http://pastebin.com/BTku1RUp

goldfire commented 5 years ago

This should now be fixed in v2.1.0 using the HTML5 Audio pool.