Skip to content

Instantly share code, notes, and snippets.

@knalli
Created April 26, 2012 17:53
Show Gist options
  • Save knalli/2501375 to your computer and use it in GitHub Desktop.
Save knalli/2501375 to your computer and use it in GitHub Desktop.
Activates AirPlay in the browser (refeshes any "video" element)
(function(){
var fn = function(){
$('video').each(function(i, video){
var $video = $(video);
if (!$video.attr('x-webkit-airplay')) {
$video.attr({
'x-webkit-airplay' : 'allow',
'airplay' : 'allow',
'controls' : 'controls'
});
var $clone = $video.clone();
$video.after($clone);
$video.remove();
if (typeof console !== 'undefined') {
console.info('Replaced video w/ url ', $clone.attr('src'));
}
}
});
};
// Just load jQuery if not already available.
if (typeof jQuery === 'undefined') {
var element = document.createElement('script');
element.onload = fn;
element.src = 'http://code.jquery.com/jquery-1.7.2.min.js';
document.body.appendChild(element);
} else {
fn();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment