0

I have a folder containing multiple video files (all with an mp4 extension) that I want to play sequentially and then loop once it plays through all of the videos in the folder. The files do not need to be exposed to the internet so I'm not worried about security, but rather my videos are played through a localhost apache2 server. I don't want to have to do something like this:

<html>
    <video autoplay>
    <source src="video1.mp4" type="video/mp4">
    <source src="video2.mp4" type="video/mp4">
    ...
    <source src="videoN.mp4" type="video/mp4">
    </video>
</html>

Because, I don't want to have to modify my index.php script every time I change the contents of my videos folder/directory, I am not looking for this. What I am looking for is something that is dynamic where the code is something more along the lines of:

1) Add all video files to a list
2) Iterate over each file in my list and then put as the video played by the video player.
3) Create a loop

The problem that I have found so far with looping and utilising PHP to echo HTML <video> tags is that it ends up showing all of the videos, one underneath the other and plays them all at the same time (as a result of the autoplay in the <video> tag). However, what I am wanting is for one video to play in the browser, then the next and so on...can anyone recommend the best way to do this please?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
  • Without writing it for you, the best suggestion would be to check out the Javascript event for 'ended' on videos [EG](http://stackoverflow.com/a/2880950/1512742), once one ends load up the next one dynamically. – Crawdingle Oct 31 '16 at 12:57
  • Awesome, thank you! I'll have a look over http://stackoverflow.com/questions/2741493/detect-when-an-html5-video-finishes and see how it goes! :) Thanks – averyrandomusername Oct 31 '16 at 13:41

0 Answers0