ScriptCommand

Description

Indicates a command was received from the current file.

Syntax
Private Sub object_ScriptCommand Type Param

ParameterDescription
Type A String value specifying the type of script command.
Param A String value specifying the value of the script command.

Remarks

Commands can be embedded among the sounds and images of an ASF file. The commands are a pair of Unicode strings associated with a designated time in the stream. When the stream reaches the time associated with the command the Player control sends a ScriptCommand event with two parameters, one parameter specifying the type of command being sent and one parameter specifying the command. The type parameter is used to determine how the command parameter will be processed. 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). URL-type commands received by the Player control are invoked automatically in your default Internet browser if the InvokeURLs property is True.

The Player control always processes incoming URL-type commands in the following manner:

  1. A URL-type command is received.
  2. ScriptCommand is called.
  3. After ScriptCommand returns, InvokeURLs is checked.
  4. If InvokeURLs is True and the command is a URL-type, the specified URL is invoked. If InvokeURLs is False or if the command is not a URL-type, the command is ignored.

When authoring an ASF file, you can specify which frame the new URL is displayed in by concatenating 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 should be launched in the myframe frame.


Type = "URL"
Param = "http://myweb/mypage.html&&myframe"

The only other type of script commands automatically processed by the Player control at this time are FILENAME-type commands. When the Player control receives a command with a FILENAME type, it resets the FileName parameter, attempts to open the file named, and begins playing the new stream immediately.

You can embed any other type of command as long as you provide reciprocal code to handle the command. Though unknown commands are ignored by the Player control, they are still handed off to the ScriptCommand event.

This event does not get called if the file is being scanned (fast forwarded or fast reversed).

The following example checks first to see whether the received command is a URL. If it's not, it displays the command in a text box. This example could be used to display text captions embedded in an ASF file. With a small amount of modification, you could check for commands of type "CAPTION" and then author ASF files using the "CAPTION" tag wherever you wanted to insert captions. You could also send VBScript commands through an ASF file and then build ActiveX HTML pages on the fly.

The example code shows the ScriptCommand event procedure.


<SCRIPT LANGUAGE="VBScript">
<!--

Sub NSPlay1_ScriptCommand(Type, Param)
  If Not (Type = "URL") Then		'Not URL?
    TextBox.Text = Type + ": " + Param	'Show command
  End If
End Sub

//-->
</SCRIPT>

See Also

InvokeURLs

Return to Player Control Reference.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.