Processing Embedded Script Commands (Windows Embedded CE 6.0)
1/6/2010
One compelling feature of Advanced Streaming Format (ASF) streams is that they can deliver script commands to the 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 that 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 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
- User-defined commands
URL-type Commands
When the Windows Media Player control receives a URL-type command, it has two tasks. The control must first interpret the URL to determine what must be opened, and then it must determine where to display that content.
The URL is interpreted in the following manner: If the URL is an absolute address (for example, http://server.com/content.html) it is launched unmodified. If it is a relative path, the control determines the base prefix according to the following rules:
- The BaseURL property of the Windows Media Player control if set to a nonempty string.
- BASE tag specified for the ASX playlist entry.
- BASE tag specified for the entire ASX playlist.
- The location of the ASF file being played minus its file name and extension.
- If the current ASF file does not begin with http:// (for example, mms://), the ActiveX container of the Windows Media Player control is requested to supply a base.
- If the control is embedded within an HTML page inside Internet Explorer, this base will be the current HTML page location minus its file name and extension.
The resulting URL is passed as the command parameter of the ScriptCommand event.
After the location of the content is determined, the control must determine where to display the content.
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-type command is ignored unless the following registry key is set. This allows the Windows Media Player control to open another instance of the browser. This key is off by default.
Note
HKEY_LOCAL_MACHINE\Software\Microsoft\MediaPlayer\Control\URLFlipping=dword:1
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.
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 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, it is ignored because the Windows Media Player control does not contain a captioning window to display the content of the command.
You can still capture the TEXT-type command using the Event Handler.
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.
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.