Last active
February 11, 2016 10:00
-
-
Save remcotolsma/fe355f54da4c4cee9200 to your computer and use it in GitHub Desktop.
Play HTML5 videos in a row.
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
<!-- Videos used from http://www.coverr.co/ --> | |
<video id="test" autoplay src="Acro/WEBM/Acro.webm" type="video/webm" class="fillWidth" controls> | |
</video> | |
<script type="text/javascript"> | |
var videoSource = new Array(); | |
videoSource[0] = 'Acro/WEBM/Acro.webm'; | |
videoSource[1] = 'Coverr-beach/Coverr-beach.webm'; | |
var videoCount = videoSource.length; | |
function videoPlay( videoNum ) {console.log( videoSource[ videoNum ] ); | |
document.getElementById( "test" ).setAttribute( "src", videoSource[ videoNum ] ); | |
document.getElementById( "test" ).load(); | |
document.getElementById( "test" ).play(); | |
} | |
document.getElementById( 'test' ).addEventListener( 'ended', myHandler, false ); | |
i = 0; | |
function myHandler() { | |
i++; | |
if ( i > ( videoCount - 1 ) ) { | |
i = 0; | |
videoPlay( i ); | |
} else { | |
videoPlay( i ); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment