Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioContext() doesn't exist on some phones?

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

like image 524
Jude Osborn Avatar asked Apr 10 '14 01:04

Jude Osborn


1 Answers

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

like image 141
Arnaud Leyder Avatar answered Sep 28 '22 11:09

Arnaud Leyder