问题
I'm teaching kids how to add audio to their JavaScript games and webpages. I knew about the HTML5 Audio API and am just now learning about the issues around the various browsers (IE surprisingly doesn't support WAV at all, etc).
However, apparently there's a new Web Audio standard I was unaware of. Chrome fully supports it. Mozilla states the following about Web Audio and Firefox:
Firefox currently supports the incompatible, Mozilla-specific Audio Data API, but it is marked as "deprecated" in favor of the W3C standard. Work has started to support the new Web Audio API in Firefox.
caniuse.com reports the following about support for Web Audio API.
I don't mind at all forcing the kids to use Google Chrome for development and sound not working in many other browsers. However, I don't want to be teaching them something that will not be in other browsers in the future.
I'm also reading about a possible alternative to Web Audio called MediaStreaming... Which is the future that I should be teaching?
回答1:
If all you need to do is play audio files, I would strongly recommend using howler.js. It doesn't have a ton of features, but it is very reliable, and works well across browsers.
The Web Audio API is definitely 'the future' of audio on the web, but it can be pretty complicated, especially if you're trying to teach it to children.
回答2:
Strictly speaking, there's really no HTML5 Audio API. But HTML5 did introduce the <audio/>
element, which is great for simple use-cases.
If you need high-precision timing, or the ability to perform DSP -- I'd go with the Web Audio API. It's still a draft as far as the W3C is concerned, but it seems fairly clear that this is the direction they're going in: http://www.w3.org/2011/audio/wiki/PubStatus
回答3:
There is no promise that the web audio API will be in all browsers but it is available in Chrome,Safari,and supposedly scheduled for Firefox. Opera has just changed their engine to webkit which is the engine used for the current batch of Web Audio API supporting browsers. Internet Explorer is completely up in the air.
回答4:
I read somewhere that microsoft is also getting engaged in the web audio api and others
Also some features like capturing audio are only supported by canary or has this changed lately? When will the entire API be supported by the standard chrome webbrowser? Another problem I had with the audio API is that when you have to do some calculations for DSP as Kevin Ennis mentioned, then javascript has problems to do so and your browser crashes. I tried to figure out why it crashes but all I could find is that javascript is not the rights choice for heavy calculations. So as far as web audio API supporting DSP I'm not convinced.
I think it will still take a lot of time since you can create a website that uses web audio API and that will be supported in a lot of browsers and that will not crash randomly. But there is not real other choice for the moment so in the future I am guessing that more and more browsers will start supporting it.
回答5:
If you are expecting the game should run only in the modern browsers you can checkout the audio library musquito. It's relatively new and it's completely based on Web Audio API.
musquito also supports audio sprites that helps very much in games.
If you are looking for a fallback mechanism for older browsers then howler.js is a good option.
[Disclaimer: I'm the creator of musquito]
来源:https://stackoverflow.com/questions/15394704/future-of-javascript-audio