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.
- Obtain a pointer to the IWMHeaderInfo interface by calling IWMWriter::QueryInterface.
- 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.
- 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.
- Get the total number of scripts in the header by calling IWMHeaderInfo::GetScriptCount.
- Loop through all of the scripts in the header one at a time using calls to IWMHeaderInfo::GetScript.
- 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.
Related topics