0

I am trying to run many videos 1 by 1 in sequence or random and my code is like this below

<div class="fullscreen-bg">
 <video loop muted autoplay poster="assets/img/poster.png" class="fullscreen-bg__video">
    <source src="assets/clip/clip<?php echo(rand(4,5,6)); ?>.mp4" type="video/mp4">
 </video>
</div> 

and it's just playing random only 1 video and after that, it's stopped.I want to do is keep playing other videos without stopping.

Thank you in advance!

Anand Jain
  • 779
  • 2
  • 10
  • 32
Soul Coder
  • 774
  • 3
  • 16
  • 40
  • http://stackoverflow.com/questions/17521012/html5-video-loop-src-change-on-end-play-function-not-working – Autista_z Jun 17 '16 at 09:43

1 Answers1

0

I hope it's help full for you I Get reference from PHP: load one of 3 html snippets randomly

PHP:

$videos = array('cloud', 'bath', 'train');
$i = rand(0, count($videos) - 1); // between 0 and $videos count minus 1

HTML:

<video loop autoplay class="StretchtoFit">
 <source src="assets/videos/<?= $videos[$i]; ?>.mp4" type="video/mp4">
 <source src="assets/videos/<?= $videos[$i]; ?>.ogg" type="video/ogg">
 <source src="assets/videos/<?= $videos[$i]; ?>.webm" type="video/webm">
</video>
Community
  • 1
  • 1