0
I found this script here on the site. it serves to give play and pause in HTML 5 videos.
But it seems to have an error, the click and pause effect only works if you have 1 video on the page, if you have 2 videos the effect only happens in the first, the second video is necessary to play the native button of the player that is a little below. someone would know to fix it, so that the effect happens in all videos that have on the page?
Video 01
<video id="videoID" preload="metadata" controls="controls" width="100%" height="100%">
<source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.mp4" type="video/mp4" />
<source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.mp4" type="video/mp4" /></video>
Video 02
<video id="videoID" preload="metadata" controls="controls" width="100%" height="100%">
<source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.mp4" type="video/mp4" />
<source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.mp4" type="video/mp4" /></video>
--------------------
Script
--------------------------------
<script>
var v = document.getElementById('videoID');
v.addEventListener(
'play',
function() {
v.play();
},
false);
videoID.oncontextmenu = function(){ return false; };
v.onclick = function() {
if (v.paused) {
v.play();
v.controls=true;
} else {
v.pause();
v.controls="";
}
};
</script>
This must be happening because you have two identical id’s for the videos. Try to change to class, changing
<video id="videoID"...
for<video class="videoID"...
(does it in both) and then in jQuery changes thevar v = document.getElementsById('videoID)
forvar v = document.getElementsByClassName('.videoID');
– gustavox