Previous | Next |
With Advanced Streaming Format (ASF), you can embed script commands into the stream. The embedded script commands are two Unicode strings associated with a designated time in the stream. One string specifies the type of command, and the other string contains the actual command. When the stream reaches the time associated with the command, the Windows Media Player control issues an event that can be captured and processed by an event-handling routine.
Note These samples are not fully functional unless Windows Media Services is installed. To download the complete suite of Windows Media Services, see the Windows Media Technologies page at the Microsoft Web site.
Both command strings are passed as parameters to the event handler. The type parameter is used to determine how the command parameter must be processed, and the command parameter specifies the action to be performed. For example, commands to launch Uniform Resource Locators (URLs) can be embedded into ASF streams. The type parameter for these commands is URL, and the command parameter contains the URL to be launched by the browser.
The Windows Media Player control automatically handles the following types of embedded script commands:
Any type of command can be embedded into an ASF stream, and reciprocal code can be written for the client application to handle the command. Unknown types of commands are ignored by Windows Media Player control; however, they are still handed off to the event-handling routine for processing.
Windows Media Encoder provides a Commands dialog box for embedding script commands into the ASF streams that it is producing. Script commands entered in the Commands dialog box are dropped into the stream, and executed by the client application.
The Commands dialog box does have limitations. Once a command is sent, it is not retained in the Commands dialog box, so users must retype the command to send it again. Another drawback is that commands stored in a script file cannot be imported into this dialog box.
The following topics are covered below:
The scripting utility sample demonstrates how to design a Visual Basic utility by using the methods and properties exposed through Automation for embedding script commands. It provides an easy–to-use interface for embedding commands into an ASF stream. The utility provides the following features, which extend the functionality of the standard interface and enable you to:
The utility also incorporates the following features of Windows Media Encoder:
The sample components are installed by clicking one of the following links. The following components are downloaded when the sample is installed:
The sample uses an .asd file containing the settings used by Windows Media Encoder. Currently there is no programmatic way to create an .asd file. Use the encoder to perform this task. For more information about creating an .asd file to specify the settings, see the Microsoft® Windows Media™ Tools documentation. The .asd file must specify the following settings:
The following steps demonstrate how to use the utility.
No error codes are returned when the script command is sent. To determine if the command was received and processed successfully, review the results on an instance of Windows Media Player connected to Windows Media Encoder. The Web page included with this sample is ideal for testing the output generated by the encoder. For instructions on using the Web page, see Viewing Output on the Sample Web Page.
Any text editor can be used to create a script file for the scripting utility. The following list outlines the format of a script file:
The Web page included with the sample uses two frames. One frame (Frame1.htm) contains the embedded instance of Windows Media Player. The other (Frame2.htm) is available for launching URL commands that are received from the scripting utility. Launching URLs in Frame 2 allows Windows Media Player to continue rendering the stream from Windows Media Encoder in Frame 1.
While it is possible to run the sample utility and the Web page on the same computer, it is recommended that you run Windows Media Encoder and the scripting utility on one computer, and the sample Web page on another.
The following list outlines the steps for using the Web page:
The status bar at the bottom of the sample utility displays whether the .asd file is loaded, and whether encoding has started.
The Start Encoding option remains disabled until a valid .asd file is loaded.
The Send Command button remains disabled until the encoding process starts successfully.
If the encoder cannot be started from the utility, or script commands are not being processed as expected on the sample Web page, try the following steps:
The sample is installed as part of the Windows Media Technologies SDK. By default, the encoder sample files are installed in \Program Files\Windows Media Components\Sdk\Samples\WMEScript.
These examples illustrate how to use HTML and Microsoft® Visual Basic® Scripting Edition, with attributes exposed by Windows Media Services.
Previous | Next |