You can't reliably detect the audio formats Web Audio can decode, and they vary both across hardware and software configurations (because the spec doesn't specify them), so your only choice is to download an entire audio file, try to decode it, and if you fail, download another and try that. Worse still, the <audio> mechanism of handing the browser a list of sources (so it can try to aggressively reduce wasted bandwidth) doesn't work because Web Audio requires you to download a full file before it can be decoded. Oops!
Shipped demos out there rely on Chrome-only Web Audio features that never made it into the spec, because Web Audio was written first as a non-portable implementation and then haphazardly turned into a spec while people were already building code against that implementation.
The spec changed after Google shipped it to the public (without putting it behind a flag or otherwise versioning it) so there are corner cases (albeit mostly small ones) where two spec-compliant implementations (Firefox and Chrome's for example) will produce different output. The only way to address some of these is update the application.
On the bright side, devs from both Mozilla and Google (among others) are working hard on addressing the issues, so it'll probably be fine in a year or so.
For future reference: look into externalizing your scripts/css into a separate file and referencing that instead of copying and pasting to every page.
I also liked the find | xargs and sed one-liners. They might as well have been speaking Aramaic.
Someone named YHWH should probably be able to understand Aramaic! :)
I try to do my part by submitting pull requests that fix it, when possible, but most of those pull requests have been sitting ignored for months.
Clearly more people need to be educated that user-agent sniffing = bad.
Feature detection simply doesn't work it many cases, and there's no alternative. Especially with new stuff like audio, sometimes function calls need to be called in different orders, have subtly different behaviors, etc., and user-agent sniffing is literally the only thing you can do.
When I programmed an HTML5 music player, calling .load() before .play() on one platform was necessary, and on another it would crash the Android browser IIRC. No choice but to use user-agent sniffing -- I probably had 20 different things that depended not just on the browser, but on the browser version.
I'd love if we could use just feature detection. Unfortunately, we have to program in the real world.
Assume good faith.
http://www.w3.org/TR/2011/WD-html5-20110113/video.html
Sometimes user-agent sniffing is the only remotely sane thing you can do. Blame the browsers, not the programmers who have to work around their "idiosyncracies".So that's the whole point. People who go on about "feature detection" and "follow the spec", and think it's that simple, really don't seem to understand what's actually going on.
[1] https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaEl...