Skip to content

Instantly share code, notes, and snippets.

@kvasdopil
Created June 8, 2021 07:27
Show Gist options
  • Save kvasdopil/040f71a3e1f6bb94caa69371aca0fc87 to your computer and use it in GitHub Desktop.
Save kvasdopil/040f71a3e1f6bb94caa69371aca0fc87 to your computer and use it in GitHub Desktop.
<body style="padding:0;margin:0">
<div>
<video id="a" src="red.mp4"
style="height:100vh" autoplay></video>
<video id="b" src="gron.mp4"
style="height:100vh;display:none"></video>
</div>
<script>
const v1 = document.querySelector('#a');
const v2 = document.querySelector('#b');
document.querySelector('#a').onclick = () => v1.play();
v1.onended = () => {
v2.style = "position:absolute;height:100vh";
v1.style = "display:none";
v2.play();
v1.currentTime = 0;
}
v2.onended = () => {
v1.style = "position:absolute;height:100vh";
v2.style = "display:none";
v1.play();
v2.currentTime = 0;
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment