Hacker News new | ask | show | jobs
by graue 4623 days ago
Ugh, why do people do that to begin with? :( I've had Web Audio for a while since I'm on the Aurora channel, and there's so many demos that refuse to work for no reason.

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.

1 comments

Sorry, you're wrong. I hate to be rude about it, but I'm really getting tired of people, who don't know any better, acting like feature detection is always the way to go.

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.

So do what the spec says by default (and if the feature appears to exist), and only deviate for particular UAs.

Assume good faith.

I agree in principle. But I've got to get stuff done in the real world. I don't have an extra week to read the 22,554 words of JUST the video/audio spec in HTML5, and try to figure out not just how all the browser versions differ from each other, but also how they differ from the spec:

    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".
I'm cheerfully assuming that you're using distilled documentation and not the literal spec. If there is, say, conflicting documentation from Mozilla and Google, then we certainly have a bigger problem.
You would assume rightly, of course. Unfortunately, Mozilla documentation, which is the best around, is sorely lacking on the details of the HTML5 audio implementation, like proper usage of the load() method, and when it's supposed to be called or not called and when. [1] And I don't really know what Google documentation you're talking about.

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...