Issue
I have an html 5 video which i remove the control buttons and added a js code in order for the user to play the video when the video is clicked. What I need to do is to bind an additional script that will redirect the page after the video plays without a page reload. Below is my js code.
function play(){
var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false);
}
And Here is my HTML5 Video Code
<video id="video" width="770" height="882" onclick="play();">
<source src="video/Motion.mp4" type="video/mp4" />
</video>
Solution
<script type="text/javascript">
// Do not name the function "play()"
function playVideo(){
var video = document.getElementById('video');
video.play();
video.addEventListener('ended',function(){
window.location = 'http://www.google.com';
});
}
</script>
<video controls id="video" width="770" height="882" onclick="playVideo()">
<source src="video/Motion.mp4" type="video/mp4" />
</video>
Here is a list of media events to which you can bind: http://dev.w3.org/html5/spec/Overview.html#mediaevents
Answered By - AlienWebguy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.