Solved

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

Posted on 2007-03-26
4
539 Views
Last Modified: 2008-02-01
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>
0
Comment
Question by:mike2401
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ethoths
ID: 18793418
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).

0
 

Author Comment

by:mike2401
ID: 18794115
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
0
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 18806488
You need to have a read of http handlers. You can do this in a shared environment. It does not have tio affect jpgs or any other file types. Quite simply you can configure all requests that match a request path to be directed to your custom handler. It the request does not match the request path then it does not get redirected.
0
 

Author Comment

by:mike2401
ID: 18860023
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
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now