GOAL: Use a NetShow video stream to fire off Macromedia Flash animation events
in another frame on the page.
To do this, we use the Flash ActiveX control, available from http://active.macromedia.com/flash2,
some script to direct the events to the NetShow control, and the NetShow ActiveX control.
CODE TO PUT IN YOUR HTML: We have set up this example using frames. The right-hand frame
called SWFLASH.HTM simply contains the Flash ActiveX control:
<OBJECT ID="SWFlash" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=2,0,0,11"
width=200 height=150 align=right>
<param NAME="Movie" VALUE="stage.swf">
<param NAME="Play" VALUE="False">
<param NAME="Loop" VALUE="False">
<param NAME="Quality" VALUE="High">
<param NAME="Scale" VALUE="ShowAll">
<param NAME="SAlign" VALUE="TR">
<param NAME="BGColor" VALUE="808080">
</OBJECT>
Note that in this Flash control, we use codebase to automatically install the Flash player
on computers without Flash, or with older versions of it.
In the left-hand frame called NetShow.htm, we have some JavaScript code and the NetShow
ActiveX control. This JavaScript function is used to receive and interpret
the events and parameters being sent from the NetShow stream.
NSPlay1 refers to the
NetShow Player control. This segment of code should come after the <TITLE>
tag in your HTML.
<script LANGUAGE="JavaScript" FOR="NSPlay1" EVENT="ScriptCommand(ScType, ScCmd)">
if (ScType == "text") {
if (ScCmd == "start")
parent.swflash.SWFlash.Play();
else if (ScCmd == "pause")
parent.swflash.SWFlash.Stop();
else if (ScCmd == "resume")
parent.swflash.SWFlash.Play();
else if (ScCmd == "stop") {
parent.swflash.SWFlash.Stop();
parent.swflash.SWFlash.Rewind();
}
}
</script>
This says that if the NetShow control sends an event (scType) called text, to plug the parameter it sends
with it (ScCmd)
into the function, which triggers
different actions based on the ScCmd type being
sent at that time. For example, if the event is Text and the parameter
is start then the subroutine called will execute the
command parent.swflash.SWFlash.Play() which will start the
Flash animation playing.
Remember that this won't work unless your ASF stream contains these events and parameters
in them.
Next, you need the NetShow control in the page. Here's the code we used:
<OBJECT ID="NSPlay1" WIDTH=144 HEIGHT=96 CLASSID="CLSID:2179C5D3-EBFF-11CF-B6FD-00AA00B4E220">
<PARAM NAME="AutoRewind" VALUE="1">
<PARAM NAME="ClickToPlay" VALUE="0">
<PARAM NAME="FileName" VALUE="sbnflash.asf">
<PARAM NAME="AllowChangeControlType" VALUE="0">
<PARAM NAME="AllowChangeDisplaySize" VALUE="0">
<Embed type="video/x-ms-asf-plugin"
src="sbnflash.asf"
filename="sbnflash.asf"
pluginspage="http://www.microsoft.com/netshow/download/player.htm"
AutoRewind=1
ClickToPlay=0
AllowChangeControlType=0
AllowChangeDisplaySize=0
width=144
height=96>
</embed>
</OBJECT>
Next, you'll need to add the events and parameters to the NetShow stream.
EVENTS AND PARAMETERS TO PUT IN YOUR NETSHOW STREAM: The preceding subroutine will
wait for events and parameters from the NetShow stream to be sent to it before it will
do anything. In this example, here are the events and parameters we used:
Time
|
Event (scType)
|
Parameter (scCmd)
|
00:29.0 |
text |
start |
00:40.0 |
text |
pause |
00:56.0 |
text |
resume |
01:05.0 |
text |
stop |
For more information about using Flash, see the Macromedia Flash Web site.
© 1998 Microsoft Corporation. All rights reserved.