Skip to content

Instantly share code, notes, and snippets.

@moqada
Created May 16, 2012 02:05
Show Gist options
  • Save moqada/2706723 to your computer and use it in GitHub Desktop.
Save moqada/2706723 to your computer and use it in GitHub Desktop.
video.js sample for mobile
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link href="https://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="https://vjs.zencdn.net/c/video.js"></script>
<script>
$(document).ready(function(){
_V_('my_video_1', {}, function(){
var player = this;
if(window.innerWidth < player.width()) {
var newWidth = parseInt(window.innerWidth * 0.9);
player.height(player.height() * (newWidth / player.width()));
player.width(newWidth);
}
});
});
</script>
</head>
<body>
<video id="my_video_1" class="video-js vjs-default-skin" controls="" preload="auto" width="720" height="480">
<source src="myvideo.mp4" type="video/mp4">
</video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment