To Add Script Data to the Header

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can include script commands in the header of an ASF file. To write script commands to the header at the time of encoding, perform the following steps. Perform these steps prior to calling IWMWriter::BeginWriting.

  1. Obtain a pointer to the IWMHeaderInfo interface by calling IWMWriter::QueryInterface.
  2. Add each desired script command by calling IWMHeaderInfo::AddScript. Each call takes the two strings separately and the presentation time to be used for the command as parameters.

When an application reads the file, it will need to retrieve all of the script commands. To find all script commands in the header of a file, perform the following steps. This should be done before starting playback.

  1. Obtain a pointer to the IWMHeaderInfo interface of the reader object (or synchronous reader object) by calling the QueryInterface method of another interface in the object.
  2. Get the total number of scripts in the header by calling IWMHeaderInfo::GetScriptCount.
  3. Loop through all of the scripts in the header one at a time using calls to IWMHeaderInfo::GetScript.
  4. Create a list of the presentation times so that your application can react to the commands at the appropriate time.

Note

When using DRM to encrypt a file, no script command can have a presentation time of 0.

 

IWMHeaderInfo Interface

IWMWriter Interface

Using Script Commands