AudioContext () doesn't exist on some phones?

I am trying 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 and webkitAudioContext does not work. The exact same code works fine on Nexus 5 and an older phone, such as the Galaxy Nexus, but not on SII. Is HTML5 sound supported on some devices? If not, can someone explain why, or point me to some documentation about AudioContext support?

The exact code I'm using is:

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

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

+4
source share
2 answers

The Webaudio API is still a working project. See here for a list of support .

Apparently, not all Android devices are ready for this ... yet. See here for an example . As with any of these new (exciting) features, you need to test support before using them on your 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
}

Link

+7
source

It depends on which browser you are using. Web audio is not supported in the native Android browser, but is supported in the latest Chrome, which is the default browser on newer devices.

I am working on SoundJS , which can allow you to create audio that will work everywhere if that's what you need.

, .

+1

Source: https://habr.com/ru/post/1535849/


All Articles