Question

I'm attempting to use AudioContext() in the latest version of Chrome (34.0.1847.114) on a Samsung Galaxy SII 4G, but for some reason AudioContext() does not exist, nor does webkitAudioContext. The exact same code functions perfectly fine on a Nexus 5 and an older phone like a Galaxy Nexus, but not the SII. Is HTML5 audio not supported on some devices? If not can anyone explain why or point me to some documentation about AudioContext support?

Exact code I'm using:

window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();

Again, this works perfectly fine on other Android phones. On the S2 I get "Uncaught TypeError: undefined is not a function".

Was it helpful?

Solution

Webaudio API is still a working draft. See here for a support list.

Apparently not all Android devices are ready for it ... yet. See here for an example. As with any of those new (exciting) features you need to test support before using them on a device:

var contextClass = (window.AudioContext || 
window.webkitAudioContext || 
window.mozAudioContext || 
window.oAudioContext || 
window.msAudioContext);
if (contextClass) {
    // Web Audio API is available.
    var context = new contextClass();
} else {
    // Web Audio API is not available. Fallback
}

Reference

OTHER TIPS

It will depend what browser you are using. Web Audio is not supported in Android Native browser, but is supported in the latest Chrome which is the default browser on newer devices.

I work on SoundJS, which can let you build audio that will work everywhere if that is something you need.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top