To Create a Reader and Open a File
[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.]
Before you can do any work with the reader, you will need to create a reader object and load a file for reading. To initialize the reader and open a file, perform the following steps.
- Create a reader object by calling the WMCreateReader function. You must specify the desired level of rights management for the new reader object. The available modes are listed in the WMT_RIGHTS enumeration type.
- Specify a file to read by calling IWMReader::Open. You must specify a reader callback interface for the reader to use. For more information about the reader callback, see To Implement Reader Messages in the OnStatus Callback.
- Wait for the reader to open the file. When you call Open to load a file, it returns almost immediately and continues processing on another thread. You should wait for operations to complete, by signaling an event when the OnStatus callback receives the WMT_OPENED status message.
The reader also supports the use of the IStream COM interface for opening files. You can implement the IStream interface any way you choose. After the desired file is opened in IStream, you can follow the steps listed above, except that you must call IWMReaderAdvanced2::OpenStream instead of IWMReader::Open in step 2.
Related topics