Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
Created November 18, 2014 17:35
Show Gist options
  • Save joshuabaker/ce50782f86f6e487f5b3 to your computer and use it in GitHub Desktop.
Save joshuabaker/ce50782f86f6e487f5b3 to your computer and use it in GitHub Desktop.
jQuery selector expression to return only sources that can be played
// 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