Skip to content

Commit

Permalink
catch audio/video test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ippa committed Aug 10, 2014
1 parent a454fd3 commit fa4c8d9
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,31 @@ var jaws = (function(jaws) {
self.file_type['ogv'] = "video";
self.file_type['mkv'] = "video";

var audioTest = new Audio();
var videoTest = document.createElement('video');
self.can_play = {};
self.can_play["wav"] = !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '');
self.can_play["ogg"] = !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '');
self.can_play["mp3"] = !!audioTest.canPlayType('audio/mpeg;').replace(/^no$/, '');
self.can_play["m4a"] = !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, '');
self.can_play["weba"] = !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '');
self.can_play["aac"] = !!audioTest.canPlayType('audio/aac;').replace(/^no$/, '');
self.can_play["mka"] = !!audioTest.canPlayType('audio/x-matroska;').replace(/^no$/, '');
self.can_play["flac"] = !!audioTest.canPlayType('audio/x-flac;').replace(/^no$/, '');
self.can_play["mp4"] = !!videoTest.canPlayType('video/mp4;').replace(/^no$/, '');
self.can_play["webm"] = !!videoTest.canPlayType('video/webm; codecs="vorbis"').replace(/^no$/, '');
self.can_play["ogv"] = !!videoTest.canPlayType('video/ogg; codecs="vorbis"').replace(/^no$/, '');
self.can_play["mkv"] = !!videoTest.canPlayType('video/x-matroska;').replace(/^no$/, '');

try {
var audioTest = new Audio();
self.can_play["wav"] = !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '');
self.can_play["ogg"] = !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '');
self.can_play["mp3"] = !!audioTest.canPlayType('audio/mpeg;').replace(/^no$/, '');
self.can_play["m4a"] = !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, '');
self.can_play["weba"] = !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '');
self.can_play["aac"] = !!audioTest.canPlayType('audio/aac;').replace(/^no$/, '');
self.can_play["mka"] = !!audioTest.canPlayType('audio/x-matroska;').replace(/^no$/, '');
self.can_play["flac"] = !!audioTest.canPlayType('audio/x-flac;').replace(/^no$/, '');
}
catch(e) {
}

try {
var videoTest = document.createElement('video');
self.can_play["mp4"] = !!videoTest.canPlayType('video/mp4;').replace(/^no$/, '');
self.can_play["webm"] = !!videoTest.canPlayType('video/webm; codecs="vorbis"').replace(/^no$/, '');
self.can_play["ogv"] = !!videoTest.canPlayType('video/ogg; codecs="vorbis"').replace(/^no$/, '');
self.can_play["mkv"] = !!videoTest.canPlayType('video/x-matroska;').replace(/^no$/, '');
}
catch(e) {
}

/**
* Returns the length of the resource list
Expand Down

0 comments on commit fa4c8d9

Please sign in to comment.