Thursday, March 22, 2012

Media Player

OK ... got the image thing in a datagrid down. Now .. trying to embed a vidio player into the app. They have training pieces they need their salespeople to view. Was looking at Shockwave player, but figured Windows Media Player might be better. How to I grab that class and consume it?

gollnicklook at the WMP10 SDK

I have done this before and is not difficult.

look at the docs but pretty much this is what you need:

<OBJECT id="Player" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" VIEWASTEXT>
<PARAM NAME="URL" VALUE="">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="balance" VALUE="0">
<PARAM NAME="currentPosition" VALUE="0">
<PARAM NAME="defaultFrame" VALUE="">
<PARAM NAME="playCount" VALUE="1">
<PARAM NAME="autoStart" VALUE="-1">
<PARAM NAME="currentMarker" VALUE="0">
<PARAM NAME="invokeURLs" VALUE="-1">
<PARAM NAME="baseURL" VALUE="">
<PARAM NAME="volume" VALUE="50">
<PARAM NAME="mute" VALUE="0">
<PARAM NAME="uiMode" VALUE="full">
<PARAM NAME="stretchToFit" VALUE="0">
<PARAM NAME="windowlessVideo" VALUE="0">
<PARAM NAME="enabled" VALUE="-1">
<PARAM NAME="enableContextMenu" VALUE="-1">
<PARAM NAME="fullScreen" VALUE="0">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIFilename" VALUE="">
<PARAM NAME="captioningID" VALUE="">
<PARAM NAME="enableErrorDialogs" VALUE="0">
<PARAM NAME="_cx" VALUE="6482">
<PARAM NAME="_cy" VALUE="6350">
</OBJECT>

the classID is specific to WMP 10
Thanks for the fast reply
Kinda had that. But .. in the ASPX page (code behind) .. how do I change the media url based on a user selection?

gollnick
after that object code, add this:

<script>

function DoShowFile(theFile)
{
document.forms[0].Player.URL = theFile;
}

</script>

then in ASP.NET codebehind, when you have chosen the media file, make sure you do a Page.RegisterStartupScript("showMedia", "<script>DoShowFile('" + theSelectedFile + "');</script>");
I placed all this within my project. Now .. I removed the line
<PARAM NAME="URL" VALUE="">
Was I supposed to? After all I'm replaceing that line with the script
document.forms[0].Player.URL = theFile;
which I update with a click event in my form
Page.RegisterStartupScript("showMedia", "<script>DoShowFile('" + "c:\Run_This\MyFile.mpeg" + "');</script>");

However ... when I do this I get nothing to play. I know the file is in the correct path (it plays when I do use the <PARAM NAME="URL" VALUE="c:\Run_This\MyFile.mpeg">

gollnick
do not remove anything from the stuff I have posted, you need to keep it all there as that could be one of many reasons why it wouldnt be playing the file.
Techno ... put it back in. Made sure I activated javascripting ... still does not work.

gollnick
interesting.
you do have WMP10 installed, and the SDK? (it should prompt you if you dont have WMP10 installed).
hmm cant think why it wouldnt work.

in one of my cells in HTML this is what I have:

<td rowSpan="2">
<OBJECT id="Player" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" VIEWASTEXT>
<PARAM NAME="URL" VALUE="">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="balance" VALUE="0">
<PARAM NAME="currentPosition" VALUE="0">
<PARAM NAME="defaultFrame" VALUE="">
<PARAM NAME="playCount" VALUE="1">
<PARAM NAME="autoStart" VALUE="-1">
<PARAM NAME="currentMarker" VALUE="0">
<PARAM NAME="invokeURLs" VALUE="-1">
<PARAM NAME="baseURL" VALUE="">
<PARAM NAME="volume" VALUE="50">
<PARAM NAME="mute" VALUE="0">
<PARAM NAME="uiMode" VALUE="full">
<PARAM NAME="stretchToFit" VALUE="0">
<PARAM NAME="windowlessVideo" VALUE="0">
<PARAM NAME="enabled" VALUE="-1">
<PARAM NAME="enableContextMenu" VALUE="-1">
<PARAM NAME="fullScreen" VALUE="0">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIFilename" VALUE="">
<PARAM NAME="captioningID" VALUE="">
<PARAM NAME="enableErrorDialogs" VALUE="0">
<PARAM NAME="_cx" VALUE="6482">
<PARAM NAME="_cy" VALUE="6350">
</OBJECT>
<script>

function DoShowFile(theFile)
{
document.forms[0].Player.URL = theFile;
}

</script>
</td>

and as for the selection of the item on ASP.NET:

Page.RegisterStartupScript("showMedia", "<script>DoShowFile('" + theFullPathToFile + "')</script>");
Strange I know... If I include my play file within the oroginal parm url ... it plays fine when the form is first shown back from the server.. I just can not plug a new url path into the player

gollnick

0 comments:

Post a Comment