busterscruggz
busterscruggz

Reputation: 67

HTML5 Video autoplay with param

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,

Upvotes: 1

Views: 1512

Answers (1)

Pedro Lobito
Pedro Lobito

Reputation: 98881

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.

Upvotes: 2

Related Questions