Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created June 2, 2016 10:07
Show Gist options
  • Save bekatom/f41318ece1fe35e9353d42ef6cda7fd1 to your computer and use it in GitHub Desktop.
Save bekatom/f41318ece1fe35e9353d42ef6cda7fd1 to your computer and use it in GitHub Desktop.
Sound utils , browser check
(function(window){
function SoundTest(){
this.browserTest = function browserTest(){
console.log("browser test");
};
this.icanPlayOgg = function icanPlayOgg(){
var ogg = document.createElement('audio');
return !!(ogg.canPlayType && ogg.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''));
};
this.icanPlayMp3 = function icanPlayMp3(){
var mp3 = document.createElement('audio');
return !!(mp3.canPlayType && mp3.canPlayType('audio/mpeg;').replace(/no/, ''));
}
}
window.SoundTest = SoundTest;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment