ASP.NET 2.0 Hosting Windows Media Player ActiveX - kinda of nightmare figuring it out
The pre-sales team wanted to have support to view video files on the web page. I am using asp.net 2.0 and I have to attend tomorrow Vista Touchdown program. Well I don't really have much time to work on this.
So I just googled as usual (or maybe msn) hehe. I found out this nice article http://steveorr.net/articles/StreamingMedia.aspx. Keep up the good work Steve. I appreciated your effort on that.
I tried on VS .NET 2003, it was kinda of amazing. I was happy with the output. Kudos.
So I told myself maybe I tried not be too happy first. It might not work on ASP.NET 2.0.
So I tried to include the MediaPlayers.csproj files into my solution. Hmm, well you kinda got some project error, but no worries. There weren't any compilations errors.
Basically it is an UI control. So you can add 2 controls into your toolbox. Try to find your MediaPlayers.dll and it will add 2 controls:
a) Audio Control
b) Media Player Control
When you tried to drag the Mesia Player control on the asp.net 2.0 web form. You will see the control looks weird, like you include an image control but you do not set the image filename path. It was like the control not working properly. You can see some differences when running this in VS .NET 2003 and VS 2005.
So I just prayed to god, hope nothing was wrong with it. No compilation error .. yes yes. I tried to run the program. Now the control was loaded. Yes yes. But wait a second, why wasn't the video loaded automatically? Since you had set the control property AutoStart = true. It worked very fine on VS .NET 2003.
Weird. Weird. So what was wrong with it?
I tried to debug the web application, but I was not able to figure what went wrong.
So I decided to follow his tutorial (which was based on asp.net 1.x). I tried to copy the object tags manually into my default.aspx (asp.net 2.0 web form). Suprisingly it worked.
Since I had tried to specify this:
<
div>
<object id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" viewastext>
<param name="autoStart" value="true" />
<param name="URL" value="Wedding - Photo Album.avi" /> // Points to the video file directly
<param name="rate" value="1" />
<param name="balance" value="0" />
<param name="enabled" value="true" />
<param name="enabledContextMenu" value="true" />
<param name="fullScreen" value="false" />
<param name="volume" value="100" />
</object>
</div>
I had tried to call the video directly. It worked. Well the control still looked funny in VS 2005 designer but it worked fine.
So where was the problem? I had figured out maybe it was the file name path.
I had compared between the VS.NET 2003 and VS 2005 sample. I had found out a difference between both of them.
Example,
VS.NET 2003 FileName = Video/Wedding - Photo Album.avi (missing tilt + slash) - functioning
VS 2005 FileName = ~/Videos/Wedding - Photo Album.avi - not functioning
I had tried a few times (in case I was still in the dream land) to make sure I was correct in analyzing this problem. So in VS 2005, it would worked if you exlcude this "~/" (2 characters).
Hope this is useful to other people looking for such solution to work on VS 2005.
Thanks to Steve for such a good tutorial again. If not, I won't be able to figure out by myself. Except there are alternatives ways to achieve that :)
Lastly, do correct me if I am wrong in anywhere. Since I am still quite new to this area. Cheers.