Your code is OK, there is a problem with your MP4 file! Try using a much smaller video like this one ( http://www.w3schools.com/tags/movie.mp4 ) to confirm that the problem is not in your code.
So, how can you achieve the same result, but with large video files? You will need two video files:
- video1 is the main video
- video2 is a loop video
Remember: in HTML5 video there is no problem playing and merging large video files, so we will use this method to play the video.
In the example below, we will play the first video, and when it ends, we will execute a function to hide video1 and then show / play video2. (Video 2 is already set to loop)
Remember to load jQuery into your head, otherwise it will not work.
<video id="video1" width="1080" height="568" poster="movie.png" autoplay onended="run()"> <source src="movie.webm" type="video/webm"> <source src="movie.ogg" type="video/ogg"> <source src="movie.mp4" type="video/mp4"> <object data="movie.mp4" width="1080" height="568"> <embed width="1080" height="568" src="movie.swf"> </object> Optional test to be displayed if the browser doesn't support the video tag (HTML 5) </video> <video id="video2" width="1080" height="568" poster="loop.png" loop> <source src="loop.webm" type="video/webm"> <source src="loop.ogg" type="video/ogg"> <source src="loop.mp4" type="video/mp4"> <object data="loop.mp4" width="1080" height="568"> <embed width="1080" height="568" src="loop.swf"> </object> Optional test to be displayed if the browser doesn't support the video tag (HTML 5) </video> <script> $( "#video2" ).hide(); function run(){ $( "#video1" ).hide(); $( "#video2" ).show(); document.getElementById("video2").play(); }; </script>
source share