Last active
October 5, 2015 23:02
-
-
Save shamangeorge/e9e390b10e4f85aff865 to your computer and use it in GitHub Desktop.
html5 video tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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