Browser Support Limitations
Web Audio API (i.e. AudioContext ) is not supported by all browsers. Some browsers may have a prefix prefixed with their provider, but older browsers do not support it at all. Therefore, to answer your question: you cannot use AudioContext in all browsers.
However, you can still use the Web Audio API in a supported browser using the discovery function (see below), or just check if your browser supports it here . Look and find your version of Safari: this site tells you if this feature is available, and if there is a prefix, which prefix you will have to use.
AudioContext Function Detection
To make sure that you can use the Web Audio API in any browser that supports it , you can use the function detection function with relative rollbacks to objects with a provider prefix. If the AudioContext object is not supported, you will stop the script and warn the user. Here is an example:
var AudioContext = window.AudioContext // Default || window.webkitAudioContext // Safari and old versions of Chrome || false; if (AudioContext) { // Do whatever you want using the Web Audio API var ctx = new AudioContext; // ... } else { // Web Audio API is not supported // Alert the user alert("Sorry, but the Web Audio API is not supported by your browser. Please, consider upgrading to the latest version or downloading Google Chrome or Mozilla Firefox"); }
Please note that at the moment webkit is the only existing AudioContext provider prefix, since Mozilla and Opera use a regular object without a prefix, and IE does not yet support the Web Audio API.
source share