Skip to content

Instantly share code, notes, and snippets.

@shamangeorge
Last active October 5, 2015 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamangeorge/e9e390b10e4f85aff865 to your computer and use it in GitHub Desktop.
Save shamangeorge/e9e390b10e4f85aff865 to your computer and use it in GitHub Desktop.
html5 video tests
<body>
<video id="sample" src="" controls="true"></video>
<video id="sample2" src="" controls="true"></video>
<script>
var videos = [
document.getElementById('sample'),
document.getElementById('sample2')
];
initHandler(0);
initHandler(1);
function initHandler(video) {
var other_video = (video + 1) % videos.length;
videos[video].addEventListener('click', function() {
videos[other_video].src = '';
var self = this;
this.src = 'http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4';
this.addEventListener('canplaythrough', function() {
self.play();
});
});
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment