Skip to content

Instantly share code, notes, and snippets.

@basvandorst
Forked from vasilisvg/webm-vimeo-fallback.php
Created November 27, 2011 19:24
Show Gist options
  • Save basvandorst/1398018 to your computer and use it in GitHub Desktop.
Save basvandorst/1398018 to your computer and use it in GitHub Desktop.
WebM fallback for Vimeo with jQuery
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var video = document.createElement("video");
var playerVersion = swfobject.getFlashPlayerVersion();
var iframeVideo = '<iframe src="http://player.vimeo.com/video/32377917?byline=0&amp;portrait=0&amp;color=ffffff" height="400" width="600">';
if ( video.canPlayType( "video/mp4;") != '' || playerVersion.major > 9 ) {
$('video').before(iframeVideo);
$('video').detach();
}
});
</script>
</head>
<body>
<video controls>
<source src="video.webm" type='video/webm; codecs="vp8.0, vorbis"'>
<p>You can <a href="video.webm">download the movie right here</a>.</p>
</video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment