Contents Index Topic Contents | |
Previous Topic: Closed Captioning Next Topic: Capturing Keyboard and Mouse Events |
Processing Embedded Script Commands
One compelling feature of Advanced Streaming Format (ASF) streams is that they can deliver script commands to the Microsoft® Windows Media™ Player control, along with the audio and video streams. These script commands are pairs of Unicode strings synchronized with a particular time in the multimedia stream. The first string identifies the type of command being sent, and the second specifies the command to process. When the stream reaches the time associated with a command, the control sends a ScriptCommand event to the web page which contains it. An event-handling routine can then respond to this event. The script command strings are passed to the event handler as parameters of the ScriptCommand event.
The Windows Media Player control automatically processes the following types of embedded script commands. Event-handling routines are not necessary to process these types of commands.
- URL-type Commands
- FILENAME-type Commands
- TEXT-type Commands
- EVENT-type Commands
- OPENEVENT-type Commands
URL-type Commands
When the Windows Media Player control receives a URL-type command, the specified URL launches in the user's default browser. If the Windows Media Player control is embedded in an HTML file that uses frames, the URL can be launched in a frame specified by the script command. This allows the Windows Media Player control to continue rendering the multimedia stream in one frame, while the browser renders images or Web pages in another frame. If the script command does not specify a frame, the DefaultFrame property determines the frame in which the new URL is launched.
Note: If the HTML file does not use frames, or if the URL-type command is launched in the same frame as the Windows Media Player control, the URL specified by the script command replaces the page rendering the stream.
You can enable or disable automatic processing of URL-type script commands by setting the InvokeURLs property. If this property is false, the Windows Media Player control ignores URL-type commands. The ScriptCommand event is still sent to the container, however, allowing for conditional processing of URL-type commands.
URL-type commands specify the relative location of the URL. The BaseURL property specifies a base HTTP URL, which the Windows Media Player control concatenates with the relative URL. The result is a fully specified URL, passed as the command parameter of the ScriptCommand event.
FILENAME-type Commands
When the Windows Media Player control receives a FILENAME-type command, it sets the FileName property to the value specified by the command. The Windows Media Player control then opens the file and begins rendering the stream from the new location. The Windows Media Player control always automatically processes FILENAME-type commands; unlike URL-type commands, they cannot be disabled.
TEXT-type Commands
When the Windows Media Player control receives a TEXT-type command, the content of the command is displayed in the captioning window of the control. The content can be in plain text or HTML.
EVENT-type Commands
When the Windows Media Player control receives an EVENT-type command, it searches for the NAME attribute of EVENT elements in the Advanced Stream Redirector (ASX) file. If the NAME attribute matches the second string of the script command, the Windows Media Player control executes the entries contained within the EVENT element. An example is to embed a script command for switching streams. For more information, see the Using ASX Files for Seamless Stream Switching section of Using ASX Metafiles
OPENEVENT-type Commands
When the Windows Media Player control receives an OPENEVENT-type command, it checks the EVENT element in the ASX file and opens the matching title. It does not play the title until the Windows Media Player control receives the actual event of the same name from an EVENT-type command.
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.