Replace Html5 Audio With Web Audio Api
Solution 1:
I think you're probably going to find at least as many bugs or edge cases with Web Audio on mobile as you're seeing using the <audio>
element. Plus, support for Web Audio on mobile platforms isn't great. If it were me, I'd be inclined to stick with <audio>
unless you have a specific use-case that can only be addressed by the Web Audio API.
Solution 2:
Actually, I'll disagree - if your goal is to play short snippets of sounds, particularly simultaneously - e.g., providing sound for a platform jumper game - Web Audio is going to be a lot easier to use, including on mobile. has issues managing multiple files/instances. On the other hand, if the problems you're running in to are due to decoding issues, or you're using mostly long files, it's not going to help, as Kevin and Brad said.
Solution 3:
I recommend SoundJS which I develop, it takes a lot of the pain out of supporting audio on multiple devices. Basically it lets you write a single code base that works everywhere and already deals with edge cases where it can.
HTML Audio element implementation on mobile devices is really terrible, so if not SoundJS I would at least recommend switching to Web Audio which works well on iOS and Android Chrome but is not supported in Android Native browser.
idbehold's comment is accurate, the most common problem with mobile devices is having to play audio inside of a user initiated event (touch). I've developed a solution to this problem, shared in the Mobile Safe Approach tutorial.
Hope that helps.
Post a Comment for "Replace Html5 Audio With Web Audio Api"