Monday, February 05, 2007

How to embed WMP in asp.net pages and how can we redirect the request when the movie ends

You can either user <img> or <object> to embed movies in *.aspx. But to capture the events, you should use the later

Use the below <object tag> to embed WMP in .aspx / html pages
<object id="VIDEO" width="100%" height="100%"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param name="URL" value="http://localhost/QaQcTraining/movies/start.wmv" />
<param name="SendPlayStateChangeEvents" value="True" />
<param name="AutoStart" value="True" />
<param name="uiMode" value="none" />
<param name="windowlessVideo" value="True" />
<param name="stretchToFit" value="true" />
</object<

Now, use the below script to capature the events of WMP
<script language=jscript FOR = VIDEO EVENT = playStateChange(NewState) type=text/jscript>
// Test for the player current state, display a message for each.
switch (NewState){
case 1:
//myText.value = "Stopped";
//alert('stoped');
location.href="qform.aspx";
//redirecting to different page after the movie plays
break;

case 2:
//myText.value = "Paused";
//alert('paused');
break;

case 3:
//myText.value = "Playing";
//alert('playing');
break;

// Other cases go here.

default:
//alert('def');
//myText.value = "";
}
</script>

No comments: