1

How can I play an HTML5 video autoplay with param in URL?

For example: http://mydomain/video?autoplay=1

Is it possible for html5 video?

I Know about: HTML5 tag,

busterscruggz
  • 67
  • 2
  • 10

1 Answers1

2

You can achieve this with autoplay:

 <video controls autoplay>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video> 

If you want to get the argument of autoplay, lets say, with php, you can use:

url : http://mydomain/video.php?autoplay=1

video.php

<?php
$autoplay = "";
if($_GET['autoplay'] === "1"){

   $autoplay = "autoplay";
}

//now we can serve the video

$html5Video = <<< LOL
 <video controls $autoplay>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video> 
LOL;
echo $html5Video;

?>

NOTE: html5 video autoplay isn't supported on most mobile browsers.

Community
  • 1
  • 1
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268