Having windows media player stream an AVI.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Having windows media player stream an AVI.

Post by Flamie »

Hey Guys,
I have this big AVI file that I want to stream to the user.
I tried the basic:

Code: Select all

 
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>
 
This seems to make the whole avi download first before opening it in windows media player, I just want to stream it to the player instead.
Since the files in questions are on my local network, I then tried to do:

Code: Select all

 
<a href="file://///networkspace/movies/file.avi">click</a>
 
Now the funny part is that if I put "file://///networkspace/movies/file.avi" in my address bar and push enter, the movie is then streamed to my player.
But clicking on the <a> tag does not do anything, its like firefox ignores that click.

Any idea(s) how to make this work?
Cheers.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Having windows media player stream an AVI.

Post by susrisha »

You cannot refer to a file in your file system using a href. Hence the browser ignores it.Typing the same file from the browser url means you are opening the file using firefox which works.
Either you need to include the file in your server root or a sub directory of server root or have to get the file into another server.
Post Reply