Skip to content

Instantly share code, notes, and snippets.

@guibranco
Created October 13, 2019 19:19
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 guibranco/4aa847a25a21e84c9cb296b6be48a885 to your computer and use it in GitHub Desktop.
Save guibranco/4aa847a25a21e84c9cb296b6be48a885 to your computer and use it in GitHub Desktop.
Sincronizar vídeos (play um, pause outros)
<video width="426" height="240" id="v1">
<source src="video1.mp4" type="video/mp4">
<source src="video1.webm" type="video/webm">
</video>
<video width="426" height="240" id="v2">
<source src="video2.mp4" type="video/mp4">
<source src="video2.webm" type="video/webm">
</video>
<video width="426" height="240" id="v3">
<source src="video3.mp4" type="video/mp4">
<source src="video3.webm" type="video/webm">
</video>
<script>
var v1 = document.getElementById("v1");
var v2 = document.getElementById("v2");
var v3 = document.getElementById("v3");
v1.onplay = function () { v2.pause(); v3.pause(); };
v2.onplay = function () { v1.pause(); v3.pause(); };
v3.onplay = function () { v1.pause(); v2.pause(); };
<script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment