Results 1 to 4 of 4

Thread: stream video from a directory

  1. #1
    Join Date
    Jul 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default stream video from a directory

    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP Code:
    <?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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your reply. when i run the code, asks if i want to download my php file...

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •