http://www.perlmonks.org?node_id=598461

TedPride has asked for the wisdom of the Perl Monks concerning the following question:

I'm storing files in a database in 64K chunks, then retrieving them to serve them to the viewer. This involves giving the following headers:
Content-Type: video/x-ms-wmv Content-Length: FILESIZE HERE Content-Disposition: attachment; filename=FILENAME HERE
...then printing the contents of the file as they are retrieved from the database. It works just fine for -downloading- the file, but when I try to show it in a player:
<object type="video/x-ms-wmv" data="PATH TO SCRIPT / FILE" width="WIDT +H" height="HEIGHT"> <param name="src" value=""PATH TO SCRIPT / FILE"> <param name="autoStart" value="0"> <a href="PATH TO SCRIPT / FILE">Download File</a> </object>
It shows the player and then dies. I know the file serves correctly, since I can download it and play it locally, and I know the player works correctly, since if I FTP in the file and point to it directly rather than to my file serve script, it loads, so the error must be in how I'm doing my headers. Has anyone run into this problem, and is there an easy fix that doesn't involve storing the files in a directory rather than a database?

Replies are listed 'Best First'.
Re: OT: Displaying Windows Media file from database?
by Thelonius (Priest) on Feb 06, 2007 at 13:25 UTC
    Make sure your mark-up works with a file before trying it with your script. I had no problems getting a script to work with this mark-up:
    <object id="MediaPlayer" width=320 height=286 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/n +smp2inf.cab#Version=6,4,7,1112"> <param name="filename" value="/cgi-bin/playwmv"> <param name="Showcontrols" value="True"> <param name="autoStart" value="True"> <embed type="application/x-mplayer2" src="/cgi-bin/playwmv" name="MediaPlayer" width=320 height=240> </embed> </object>
Re: OT: Displaying Windows Media file from database?
by Anonymous Monk on Feb 06, 2007 at 08:22 UTC
    Why does the player die?
Re: OT: Displaying Windows Media file from database?
by TedPride (Priest) on Feb 07, 2007 at 04:18 UTC
    I already said it works properly with a file that's not served from a script. It's not the embed code that's the problem, and it's not the file serve script either (it works fine for downloading the file...), it must be that the headers aren't serving the file the right way to work with the embed.
      so how are the headers different?