0

I try to make a website on my homeserver, which can play videos. I use XAMPP for Windows 7.2.33. PHP snippet of function:

?>
<div class="row">
 <div class="col-lg-12 col-md-12 mb-4">
   <video src="<?=$src?>" autoplay controls></video>
 </div>
</div>
<?php

$src is the correct path of the mp4 file.

$src = "F:/Avatar - The Last Airbender/s01/e01.mp4"

The video player appears, but does not play the file. I have tried the tag in a simple .html file, and it worked out of the xampp, but not in the xampp's htdocs dir. Current result I assume there is something with apache, but I don't know. Do you have any idea what the problem is, or how should I stream videos from php?

VC.One
  • 14,790
  • 4
  • 25
  • 57
faron
  • 11
  • 1
  • What's the value of `$src`? Its either not found, or not a supported format – Lawrence Cherone Oct 02 '20 at 18:42
  • @LawrenceCherone value of $src :"F:/Avatar - The Last Airbender/s01/e01.mp4" When I tried in a simple html file, not using xampp it worked. Open with xampp like http://localhost/index.html does not work. The video player appears, but does not play the file. – faron Oct 02 '20 at 19:03
  • probably you have an error in your console. The link should be a URL not a file path. – ADyson Oct 02 '20 at 19:35
  • 1
    yeah as ADyson said *the link should be a URL not a file path*, you would need to move the files into htdocs directory or mount H: as a directory in htdocs, or make a script which proxies it from that directory (not trivial if you want seeking support, see [this](https://stackoverflow.com/questions/11340276/make-mp3-seekable-php/11341766#11341766)). basically if done over HTTP, the file has to be in an accessible location within the webroot – Lawrence Cherone Oct 02 '20 at 19:46
  • 1
    **(1)** Test by copying the file `e01.m4`to your same place as your PHP file and just set as `$src = "e4.mp4";` ... Does it work now? **(2)** Just **don't use spaces** in a URL path (it gives guaranteed problems). If you need a folder name with gaps then maybe use underscores in the name _eg:_ `Avatar_-_The_Last_Airbender` as example – VC.One Oct 03 '20 at 03:52
  • Thank you guys!! As ADyson said, it should be a URL not a file path. And LawrenceCherone 's suggestions are pretty good. – faron Oct 04 '20 at 15:01

0 Answers0