AudioContext() doesn't exist on some phones?

我与影子孤独终老i 提交于 2019-12-04 07:45:58
Arnaud Leyder

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!