To Seek By Frame Number Using the Asynchronous Reader
[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.]
The asynchronous reader object can be used to seek to the frame numbers of video streams in an ASF file. To use frame-based seeking, the file loaded in the reader must be indexed by frame. Each individual video stream can be indexed. To determine whether a stream has been indexed by frame, you can check the g_wszWMNumberOfFrames attribute in the header of the file by calling IWMHeaderInfo::GetAttributeByName.
To seek data in an ASF file by frame number using the asynchronous reader, perform the following steps.
- Obtain a pointer to the IWMReaderAdvanced3 interface of the reader object by calling IWMReader::QueryInterface.
- Set the starting frame number and duration by calling IWMReaderAdvanced3::StartAtPosition. You must specify the stream number of a frame-indexed video stream. The reader will synchronize the rest of the outputs to the presentation time of the specified frame of the specified stream and begin delivering output samples.
- Handle the samples as you normally would in your implementation of the IWMReaderCallback::OnSample method.
Related topics