Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-26
4
Medium Priority
?
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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