Page 1 of 1

Having windows media player stream an AVI.

Posted: Sun Feb 15, 2009 11:30 am
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.

Re: Having windows media player stream an AVI.

Posted: Mon Feb 16, 2009 1:09 am
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.