Skip to content

Instantly share code, notes, and snippets.

@XuankangLin
Created April 23, 2013 06:52
Show Gist options
  • Save XuankangLin/5441353 to your computer and use it in GitHub Desktop.
Save XuankangLin/5441353 to your computer and use it in GitHub Desktop.
provide several useful functions for handling Web Audio API
// check if support Web Audio
var supportWebAudio = (function(){
// check <audio> tag first
var ele = document.createElement('audio');
if (!ele) {
return false;
}
// check Web Audio's context
try {
var ctx = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
return ctx ? true : false;
} catch (e) {
return false;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment