Google Answers Logo
View Question
Q: ASP and Windows Media HTTP Streaming ( Answered 5 out of 5 stars,   2 Comments )
Subject: ASP and Windows Media HTTP Streaming
Category: Computers > Programming
Asked by: morgile-ga
List Price: $100.00
Posted: 24 Jan 2004 06:34 PST
Expires: 23 Feb 2004 06:34 PST
Question ID: 299668

I am building a web site that will allow users to view 
streaming video content. the web site is built using
ASP and SQL Database. I am using Windows Server 2000
and HTTP Streaming for the video.

Only authorized users are able to see the steaming video content. (different
content for different users). I already know
if the user is authorized in my ASP code (session variables)
and which files he may view.

However, since eventually I render the following code to the browser:

  standby="Loading Microsoft® Windows® Media Player components..."
  height="269" >

<PARAM NAME="FileName" VALUE="somefolder/somefile.wmv">

the wmv URL (somefile.wmv) can be copied by the user and be used
in the future without logging in to the site.

please notice:
I cannot implement the protection of the WMV files with NTFS permissions
since my user base is controlled from the DB and I do not want to supply
my users with additional usernames and passwords.
A good answer will not involve per-user manipulation of NTFS permissions.

A possible solution I thought of is to build an ASP page that will be
used as a buffer:

  <PARAM NAME="FileName" VALUE="wmvbuffer.asp&videoid=someid">

and then wmvbuffer.asp will check that the session is valid, 
read the video file and send it to the media player.
problem is that sometimes files are too big and cannot
be read in to memory. if such approach is reccomended,
I'll need some kind of a buffering mechanism that will
read a small part of the file and send it to the user.

What do I need?
1. Explanation of the suggested approach
2. Code snippets
3. I must be assured that the approach was somehow tested before
4. I may consider a 3rd party solution (like a activeX control that
buffering for me) if licensing of this solution is cheap.

Clarification of Question by morgile-ga on 25 Jan 2004 18:14 PST
Regarding big_m-ga Comment:

It actually got me thinking for a moment.. This indeed could have
been a quick and dirty solution.. Cool.!

Nevertheless, Its enough that I have 10-20 users using the system
simultaneously to clog the server. It'll have to copy 15Mb Files every
few seconds.

Subject: Re: ASP and Windows Media HTTP Streaming
Answered By: majortom-ga on 26 Jan 2004 08:07 PST
Rated:5 out of 5 stars
You can open a binary file using an ADODB.Stream object. This is
common and there are many references to this being done successfully,
including an
official Microsoft HOWTO:

The problem with all of these examples is that they read the entire file
into a single binary data array object, which you alluded to as a
serious memory problem. Happily there's a way to read the file a piece
at a time, and a complete, working solution is shown here:

IMPORTANT: there are several code examples on that page; you want the
one that begins with this notice:

'Made By Adam Smith on Aug 8, 2003 for

The copyright statement on that code states that you are free to use
it as you see fit, and the express goal of the programmer was to
address the very same issue that you are attempting to address. I
suspect the code might be slightly faster without the extra
Response.Flush calls inside the while loop, but it works exactly as
shown. I have tested it successfully on my own workstation. All I had
to do was set FileName and ContentTypeOf appropriately at the top of
the script, name it "fileread.asp," and access it with my browser. I
am sure this will integrate smoothly into your script(s).

One more important note: if you test this on a workstation running a
local copy of Internet Information Server and you have antivirus
software on that workstation, be sure to read this Microsoft article
to avoid "hangs" of the script:

But this is only a local testing concern and should not affect real servers.
morgile-ga rated this answer:5 out of 5 stars
Thank you, great answer, simple and to the point.

Subject: Re: ASP and Windows Media HTTP Streaming
From: big_m-ga on 25 Jan 2004 16:07 PST
Why not copy the WMV file to a temporary file, send this file to the
client, and then (after a timer expires) delete the temporary file.
Then you can have the file available for the user for some time, but
later it will be deleted and therefore no longer accessable.

Big M.
Subject: Re: ASP and Windows Media HTTP Streaming
From: morgile-ga on 27 Jan 2004 06:19 PST
Hi, Thanks for the answer, It looks like the right thing to me.
I'm checking now to see if it works, but it sure looks promising!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy