Player6.ScriptCommand (deprecated)

Windows Media Player SDK banner art

This page documents a feature of the Windows Media Player 6.4 ActiveX control. We recommend that you migrate your content to use the Windows Media Player 9 Series ActiveX control. For more information about the Windows Media Player 9 Series ActiveX control, see the Windows Media Player 9 Series SDK.

This event occurs when the 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 a Windows Media 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 a Windows Media 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:

  1. The control receives the embedded script command.
  2. The ScriptCommand event occurs.
  3. 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.
  4. All other event types are processed by the Media Player by default.

When you author a Windows Media 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 = "https://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 Windows Media 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 Sub

This example could be used to display text captions embedded in a Windows Media file. Another approach would be to check for commands of type "CAPTION" and then author Windows Media files with "CAPTION" tags wherever you want to insert captions. You could also send Microsoft Visual Basic Scripting Edition (VBScript) commands through a Windows Media file and then build Microsoft ActiveX HTML pages on the fly.

Requirements

Version: Windows Media Player version 6.4.

Library: Use msdxm.ocx.

Platform: Windows 98 Second Edition or higher.

See Also