Link to home
Start Free TrialLog in
Avatar of mike2401
mike2401Flag for United States of America

asked on

Can this FileStream be the source for Embedded Windows Media Player on WebPage?

Can this FileStream be the source for Embedded Windows Media Player?

The code below launches Windows Media Player and indeed plays the video in a NEW window.

Is there any way I use this video stream and instead EMBED the PLAYER on my web page?

Background:  I’ve renamed my video file from: myvideo.wmv to myvideo.wmv.resources  to prevent anyone from being able to directly access it using its URL.  This little trick relies on the fact that any files ending in “.resources” are forbidden from being served.

Problem:
When I use myvideo.wmv.resources  with an EMBEDED windows media player (code further down), it first complains about the non-normal file extension, but if I click ok, will indeed plays embedded on my web page.

Any & All help will be very much appreciated.

Thanks,
Mike


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim MyFileStream As FileStream
        Dim FileSize As Long

        MyFileStream = New FileStream(MapPath("/once/myvideo.wmv.resources"), FileMode.Open)
        FileSize = MyFileStream.Length

        Dim Buffer(CInt(FileSize)) As Byte
        MyFileStream.Read(Buffer, 0, CInt(FileSize))
        MyFileStream.Close()

        Response.ContentType = "video/x-ms-wmv"
        Response.OutputStream.Write(Buffer, 0, FileSize)
        Response.Flush()
        Response.Close()

    End Sub
End Class

Here’s the embed which first complains about the file ext.

<object id='mediaPlayer' width="320" height="285"
                          classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
                          codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
                          standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
                          <param name='fileName' value="<%  Response.Write(MyFileNamewithResourcesAtEnd)%>"/>
                          <param name='animationatStart' value='true'/>
                          <param name='transparentatStart' value='true'/>
                          <param name='autoStart' value="true"/>
                          <param name='showControls' value="true"/>
                          <param name='loop' value="false"/>
                          <param name="Volume" value="100"/>
                         
                          <embed type='application/x-mplayer2'
                            pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
                            id='mediaPlayer2' name='mediaPlayer' displaysize='4' autosize='-1'
                            bgcolor='darkblue' showcontrols="true" showtracker='-1'
                            showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="285"
                           
                            src="<%  Response.Write(myurl)%>" autostart="true" designtimesp='5311' loop="false">
                          </EMBED>
                          </object>
Avatar of ethoths
ethoths

Not really sure what your trying to do and what the problem is. It sounds like you want to play media file on a web page but prevent direct browsing access. If so have you considered writing a handler to server up the wmv files?

You can configure your site to direct requests from wmv files to you special bit of code rather then the normal asp.net page handeler. In that code you can apply any logic you like before dishing up the media (or not).

Avatar of mike2401

ASKER

Thanks. And yes, I'm trying to prevent direct browser access to certain WMV (and JPG) files without using IIS permissions.  (My technique works fine for JPG).

Since I'm in a shared host environment, I can't redirect all wmv requests to the asp engine for handling.  And, even if I could redirect certain types of file to asp for processing, I wouldn't want to redirect JPG's cause that would really kill performance.

In a nutshell, the embedded windows media player complains when the extension isn't .wmv (even though it is a valid video binary), and will play correctly if I click OK on the warning.

I suspect the solution is probably similar to what people do when they retrieve a blob of video from a sql server and want it played by an embedded windows media player on a web page.

Do they first have to extract the video and save it to a file, and then use the filename param for the embed object,

OR, do they somehow retrieve the video from the database, and pass it to the player using some other param?

Regards,
Mike

I
ASKER CERTIFIED SOLUTION
Avatar of ethoths
ethoths

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Going at this from another direction, I wonder how the people who store videos inside a sql database do it?

Do they have to retrieve the video into a local file which would then be referenced as a filename from a windows media player control on a web page?

Mike