View Full Version : stream video from a directory
resnostyle
07-23-2007, 12:40 AM
hey guys,
I want to work on a script that checks a directory for video files and plays them in windows media player. what is a good tutorial or source for help?
Are there any books that are good for learning php? I know alot of the basics so, I dont want a really elementary book.
Thanks
djr33
07-23-2007, 12:51 AM
<?php
$dir = 'my/dir/and/stuff/'; //set directory. Use two [single] quotes for blank.
if (!isset($_GET['file'])) { die('No file specified.'); }
$file = $dir.$_GET['file'];
if (file_exists($file)) { die('File does not exist.'); }
header('Content-type: movie/wmv'); //completely random guess-- look this up on google
header('Content-length: '.filesize($file));
readfile($file);
?>
Just call that then with:
myphp.php?file=filename.wmv
Embed that on the page, and I think it should work.
However, this doesn't give all that much security, since it can be accessed just like any other link. I'm not sure if that's your goal, though.
resnostyle
07-24-2007, 02:16 AM
thanks for your reply. when i run the code, asks if i want to download my php file...
djr33
07-25-2007, 11:50 PM
I *think* that will then be downloading the movie. That's the point.
If you wanted to embed it instead, just use the url to the page as the url to the wmv in the embed tags.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.