audioplaytest.js 1005 B

123456789101112131415161718192021
  1. function isAudioSupported(mime){
  2. var audio = new Audio();
  3. var bMime = null;
  4. if (mime.indexOf("ogg") != -1 || mime.indexOf("vorbis") != -1) {
  5. bMime = 'audio/ogg; codecs="vorbis"';
  6. } else {
  7. bMime = mime;
  8. }
  9. //return a true of the browser can play this file natively, or if the
  10. //file is an mp3 and flash is installed (jPlayer will fall back to flash to play mp3s).
  11. //Note that checking the navigator.mimeTypes value does not work for IE7, but the alternative
  12. //is adding a javascript library to do the work for you, which seems like overkill....
  13. return (!!audio.canPlayType && audio.canPlayType(bMime) != "") ||
  14. (mime.indexOf("mp3") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) ||
  15. (mime.indexOf("mp4") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) ||
  16. (mime.indexOf("mpeg") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined);
  17. }