-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Creates a pool of activated HTML5 Audio objects for use on mobile. #1008
Conversation
c0ef595
to
4e5365b
Compare
@scottanderson42 I couldn't get it to work on my case (from issue #1031). Any ideas why? All I did was to simply turn on the new feature. Also, when I first tried to import Howler from your PR, I had to fix the following missing |
It looks like using HTML5 audio on iOS is currently broken but this change would fix it. This is important because falling back to HTML5 is necessary for many reasons, one of which is adjusting audio playback rate while holding pitch constant (which is not possible via Web Audio). @scottanderson42 do you have time to address @gugiserman's syntax corrections? If not I can open a new pull request as I need to use this pooling unlock feature :). |
Currently the WebAudio API is unlocked via user interaction in the _enableMobileAudio method. This does not however unlock HTML5 Audio as well. Since HTML5 Audio objects must be individually unlocked, using them without user interaction can be accomplished by pooling a number of activated Audio objects at the same time WebAudio is unlocked, and using those pooled objects whenever a new sound is requested. Changes: - Adds a private mobile audio pool to the Howler object. - Adds a new Howler global configuration named "mobileHtml5AudioPoolDefaultSize" that governs the number of pooled Audio objects, with a starting value of 10. - Fill the pool in _enableMobileAudio(). - Use Audio objects from the pool when a Sound object is created in HTML5 mode. - An over-scheduled pool can be configured via the Howler.shouldMobileHtml5AudioPoolErrorWhenEmpty option to still return Audio objects, however they are not guaranteed to be unlocked. This option defaults to 'false'.
4e5365b
to
d000cff
Compare
@gugiserman Thanks for spotting those, too much CoffeeScript in my past. @LukeWalsh I've incorporated the fixes. |
@scottanderson42 is this working for you when testing locally? I am trying to use it but still not able to get an HTML5 audio file to work on iOS. In inspecting the Howler object I see that the pool is properly created however the audio is shown as stuck in the "loading" state when I create a Howl object with html5: true. I also see that onloaderror is firing during the creation of this Howl & giving error code 4. I know it's not an issue with the audio file not being supported by mobile Safari because I'm able to load the same audio file directly in the HTML with:
|
@goldfire have you tried html5 audio on iOS recently? |
@LukeWalsh I have tested it on iOS11. I have not yet tested on 12. |
Hmm ok, I'm running iOS 12 but I would be surprised if that's the difference. And what are you doing in your test? I am using React and creating a Howl object with html5: true in componentDidMount, then I have a button that calls .play() on that Howl object. On the same page I'm loading the same src file using |
@scottanderson42 did you upgrade to iOS12 and have a chance to test? I'm wondering if there's something I'm missing that's causing my test to fail. If everything is working then this is a useful fix to merge. |
Sorry about the delay. I've been out of town and going out of town again today, but I should have time during Thanksgiving week to get caught up on this and some other open PRs and issues and hopefully get this all into a 2.1.0 release. |
This is now merged into master with some tweaks/simplifications that I've made. I've got some more changes in the autoplay area to get pushed up and then after some further testing I'll try to have 2.1.0 released early next week. Thanks for the work on this!! |
Currently the WebAudio API is unlocked via user interaction in the _enableMobileAudio method. This does not however unlock HTML5 Audio as well. Since HTML5 Audio objects must be individually unlocked, using them without user interaction can be accomplished by pooling a number of activated Audio objects at the same time WebAudio is unlocked, and using those pooled objects whenever a new sound is requested.
Changes: