Solved

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

Posted on 2007-03-26
4
549 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Injector with Web Service 4 43
start a process from a service 3 23
Send SMS from VB via Sierra Wireless Modem 2 22
MVC DDL Json Not Binding to Model 2 13
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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