video in html5 - how to add two videos [duplicate]

1

I wanted to make two videos run, one after another, tried the way below but it did not work. Can you do that?

<video width='400' height='300' controls loop>
   <source src='video.mp4' type='video/mp4'>
   <source src='video2.mp4' type='video/mp4'>
</video>
    
asked by anonymous 28.11.2017 / 16:50

1 answer

0

You can do this:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<video id="v1" width="320" height="240" controls="controls" onended="vidplay(2)">
<source src="http://content.bitsontherun.com/videos/bkaovAYt-52qL9xLP.mp4"type="video/mp4">
<object data="" width="320" height="240">
<embed width="320" height="240" src="Yes Bank Advertisment.mp4">
</object>
</video>

<video id="v2" width="320" height="240" controls="controls" onended="vidplay(1)">
<source src="http://content.bitsontherun.com/videos/bkaovAYt-52qL9xLP.mp4"type="video/mp4">
<object data="" width="320" height="240">
<embed width="320" height="240" src="Yes Bank Advertisment.mp4">
</object>
</video>

<script type="text/javascript">

var video = document.getElementById("v1");
video.play();

function vidplay(i) {

  var video = document.getElementById("v"+i);
  if (video.paused) {
    video.play();

  } else {
    video.pause();

  }

};

</script>

</body>
</html>

I've edited here and it works perfectly, stay on one side of the other! one at a time, see if it helps you

I need to make javascript control this, I used the onended tag that performs a function call when the video ends

    
28.11.2017 / 16:54