Skip to content

Instantly share code, notes, and snippets.

@kvasdopil
Created June 3, 2021 12:53
Show Gist options
  • Save kvasdopil/742cf4dbf000bff255f018cd5b88fcaa to your computer and use it in GitHub Desktop.
Save kvasdopil/742cf4dbf000bff255f018cd5b88fcaa to your computer and use it in GitHub Desktop.
<div>
<video id="a" src="red.mp4" style="width:300px" autoplay></video>
<video id="b" src="gron.mp4" style="width:300px"></video>
</div>
<button id="btn">play</button>
<script>
const v1 = document.querySelector('#a');
const v2 = document.querySelector('#b');
document.querySelector('#btn').onclick = () => v1.play();
v1.onended = () => {
v2.play();
v1.currentTime = 0;
}
v2.onended = () => {
v1.play();
v2.currentTime = 0;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment