Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions detect/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

if(!has("dom")){ return; }

var video = document.createElement("video");
var video = document.createElement("video"),
// IE9 is reported to throw errors if "Desktop Experience" is not installed
// have a look at this:
// https://github.com/Modernizr/Modernizr/issues/224
canPlayType = function( type ) {
try {
return video.canPlayType( type );
} catch( e ) { }
return false;
};

addtest("video", function(){
return has.isHostType(video, "canPlayType");
Expand All @@ -14,15 +23,15 @@
// workaround required for ie9, who doesn't report video support without audio codec specified.
// bug 599718 @ msft connect
var h264 = 'video/mp4; codecs="avc1.42E01E';
return has("video") && (video.canPlayType(h264 + '"') || video.canPlayType(h264 + ', mp4a.40.2"'));
return has("video") && ( canPlayType(h264 + '"') || canPlayType(h264 + ', mp4a.40.2"'));
});

addtest("video-ogg-theora", function(){
return has("video") && video.canPlayType('video/ogg; codecs="theora, vorbis"');
return has("video") && canPlayType('video/ogg; codecs="theora, vorbis"');
});

addtest("video-webm", function(){
return has("video") && video.canPlayType('video/webm; codecs="vp8, vorbis"');
return has("video") && canPlayType('video/webm; codecs="vp8, vorbis"');
});

})(has, has.add, has.cssprop);