Created
November 18, 2014 17:35
-
-
Save joshuabaker/ce50782f86f6e487f5b3 to your computer and use it in GitHub Desktop.
jQuery selector expression to return only sources that can be played
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Selector expression to return only sources that can be played | |
$.expr[':']['canplaytype'] = function(a) | |
{ | |
var video = document.createElement('video'); | |
return !!video.canPlayType && video.canPlayType(a.type); | |
}; | |
// Usage | |
var playable = $('video source:canplaytype').length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment