Contents Index Topic Contents | |
Previous Topic: ReadyStateChange Next Topic: Warning |
ScriptCommand Event
Occurs when the Microsoft® Windows Media™ Player control receives a synchronized command or URL.
Syntax
JScript <SCRIPT FOR="MediaPlayer" EVENT="ScriptCommand(sType, sParam)" LANGUAGE="JScript"> //insert script commands// </SCRIPT>VBScript <SCRIPT LANGUAGE="VBScript"> Sub MediaPlayer_ScriptCommand(sType, sParam) //insert script commands// End Sub </SCRIPT>Parameters
sType String value specifying the type of script command. sParam String value specifying the value of the script command. Remarks
Commands can be embedded among the sounds and images of an .asf file. A command is a pair of Unicode strings associated with a designated time in the stream. When the stream reaches the time associated with the command, the Windows Media Player control sends a ScriptCommand event with two parameters. The sType parameter specifies the type of command and the sParam parameter specifies the command. The type parameter determines how the Windows Media Player control processes the command parameter. Any type of command can be embedded in an ASF stream to be handled by the ScriptCommand event.
One type of command is a URL (Uniform Resource Locator). The Windows Media Player control automatically invokes URL-type commands in your default browser if the InvokeURLs property is true.
The Windows Media Player control always processes incoming URL-type commands in the following manner:
- The control receives the embedded script command.
- The ScriptCommand event occurs.
- If InvokeURLs is true and the command is a URL-type, the control invokes the specified URL. If the command is a URL-type but InvokeURLs is false, the command is ignored.
All other event types are processed by the Media Player by default.
When you author an .asf file, you can specify the frame in which the new URL is displayed by appending two ampersands and the name of the frame in the parameter field. The example below illustrates typical ScriptCommand parameters. It specifies that the URL mypage will be launched in the frame myframe.
Type = "URL" Param = "http://example.microsoft.com/mypage.html&&myframe"Other types of script commands automatically processed by the Windows Media Player control include FILENAME, TEXT, EVENT, and OPENEVENT commands. For the FILENAME type, the Windows Media Player control resets the FileName property, attempts to open the specified file, and begins playing the new stream immediately. For the TEXT type, the Windows Media Player control displays the associated text in the captioning window of the Windows Media Player. For the EVENT type, the Windows Media Player control executes instructions defined for the specified event. For the OPENEVENT type, the Windows Media Player buffers the associated EVENT-type command for execution when it receives the corresponding EVENT from the ASF stream.
You can embed any other type of command as long as you provide corresponding code to handle it. The Windows Media Player control ignores unknown command types, but still hands them off to the ScriptCommand event.
This event does not occur if the file is being scanned (fast-forwarded or fast-reversed).
Example
The following example first checks whether the received command is a URL. If not, it displays the command in a text box.
Sub MediaPlayer_ScriptCommand( eventType, Param ) If Not (eventType = "URL") Then 'Not URL? TextBox.Text = eventType + ": " + Param 'Show command End If End SubThis example could be used to display text captions embedded in an .asf file. Another approach would be to check for commands of type "CAPTION" and then author .asf files with "CAPTION" tags wherever you want to insert captions. You could also send Microsoft® Visual Basic® Scripting Edition (VBScript) commands through an .asf file and then build Microsoft® ActiveX® HTML pages on the fly.
See Also
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.