Reputation: 23
Im green with JS, bit i would like to implement to my website html 5 video.
video code looks like this
<video id="myvideo" style=width:600px; height:550px controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
I would like to make video pasue on 15 second and trigger an event Now my event is on button button code
<button onclick="myFunction()">Watch</button>
<script>
function myFunction() {
RC_STARTGATE();
}
</script>
Edit: Button is temporary solution. I would like to remove button and something like this: Video starts=> after 15 seconds it pauses=> and triggers same event as button did RC_STARTGATE().
Edit 2: Great! now i need to get button removed and start timeout when video starts.
var vid = document.getElementById("myVideo");
function myFunction(){
vid.play();
setTimeout(function(){
vid.pause();
}, 15000); //
setTimeout(function(){
RC_STARTGATE();
}, 15000); //
}
Upvotes: 0
Views: 12480
Reputation: 1372
When the button is clicked, the video starts playing, and after 15 seconds you want it stopped?
var vid = document.getElementById("myvideo");
function myFunction(){
vid.play();
setTimeout(function(){
vid.pause();
}, 15000); //15 second timeout in milliseconds
}
EDIT 2
To remove the button, add an id (<button id="mybtn">
) so you can reference and remove it like this:
var btn = document.getElementById("mybtn");
btn.parentElement.removeChild(btn);
Upvotes: 2