Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Windows Media Player - dynamic source from db

Hi,  With graphics I have done this:
<img src=<%=some.asp%>>
The some asp page sets its response.ContentType = "image/jpg" or whatever.  This works fine.  

What I want to do is the same thing but with the windows media player control.  From what I have seen there are two parameters 'properties' :


<PARAM NAME="FileName" VALUE="some.asf"> works fine...however

<PARAM NAME="FileName" VALUE="some.asp"> does not even though I have set the ContentType to "video/x-ms-asf"

Is there some reason why this will not work??

here is the relevent code from my "some.asp"
        Response.contenttype = "video/x-ms-asf"
     Response.binarywrite rs.fields(0)

The player page includes:
<OBJECT ID="MediaPlayer"  
            <PARAM NAME="FileName" VALUE="some.asp?uid=5">

Any done this before?

  • 3
1 Solution
Does the "some.asp" have code in which you check Session variables ?? Because mediaplayer will not pass the Session variables from the browser.

It might help to use:

<img dynasrc="<%=some.asp%>">

it will work on most multimedia content.
chisholmdAuthor Commented:
Initially, Yes I was using a session variable in the some asp to know which record to pull from the db to retrieve the ASF stream.  However I removed it in my testing adn just hardcoded it to retrieve a specific record and it still didn't work.  

The structure of the some.asp is bassically this
...set up connection object...
...format sql string...
...retrieve recordset of one field...
...change content type to  "video/x-ms-asf"
...do a Response.binarywrite rs.fields(0)...

(The ASF's in question are only about 25kb, these are not massive videos or anything, They only contain audio.)

I tested the connection object and record retreival and I know I am getting the record back. I also confirmed that the field is populated with the ASF. (Its in a IMAGE field I don't know yet if it retained it's integrity until I can get it out and play it. My next test will be just to write it back out to a file and see if it plays.)

I woke up this morning and my first thought was "stream object" perhaps I have to 'convert?' it to a stream object of some sort instead of doing a binary write???

My last resort will be to simply save the ASF to disk on upload, with a name containing the appropriate record ids but this is the least elegent solution for me.

I'll try <img dynasrc="<%=some.asp%>"> but will that play  an audio ASF ?? Guess I'll find out. :)


chisholmdAuthor Commented:
w00t!!!  Thanks sybe, the <img dynsrc=''> worked very well.

I am able to re-source it by pointing to my .asp including my query strings. e.g.

function playit(vWhich){
     player.dynsrc= 'some.asp?uid=<%=uid%>&which='+vWhich

<img id=player dynsrc=''>

So on a given page I might have 3 sound files per 'question record'  I can trigger which to play based on the parameter passed.  

1 function
1 asp page
1 happy coder :)

Now I have to test in NS6/7 :(

Thanks again,

chisholmdAuthor Commented:
I know it might not be the most efficient thing to save my ASF's in my SQL Server but now that I can all my content is in the database which help my stay organized and allows my to reuse it from other sources VB App's for example.

thanks again


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now