Solved

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

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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