Share via


SampleMediaParser Functional Design (Compact 7)

3/12/2014

This article describes the sample plug-in, SampleMediaParser, which identifies a file as a music or video entity based on its file name extension. By taking advantage of registry search efficiency, this design uses registry entries to map file name extensions to entity types. The design uses name/data entries stored in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MLib\EntityExtensions. The sample plug-in implements GetEntityType to identify a file with extension .wav as a music entity and a file with extension .mp4 as a video entity. It implements ExtractMetadata to collect metadata for the file and return it to Media Library as one of these entities. For information about this implementation, see the listings for SampleMediaParser.h and SampleMediaParser.cpp.

SampleMediaParser supports only file system-related metadata. It collects this metadata without inspecting the contents of the file.

In the ExtractMetadata method, a registry query uses the file extension as a value name and returns the entity type as value data of type REG_SZ. This string matches one of the enumerated Media Library EntityId values; see mlibdll_id.h for a complete list of the EntityId values. SampleMediaParser uses the entity to compose a metadata collection with the correct PropertyId values. For a complete list of the PropertyId values, see mlibdll.id.h.

If an entity extension is not found among the EntityExtensions values in the registry, the sample plug-in returns S_FALSE. This result indicates that the media parser does not support the media file, and Media Library moves to the next media parser until it finds support for the media file, or until all media parsers have been tried. If Media Library does not find a media parser for a specific media file, Media Library does not add the information for the file to the database and does not manage the file.

A custom media parser that identifies file types that are not supported by all other parsers has a number of advantages. One advantage is that Media Library clients, such as the Windows Media Player user interface, have a better view of a watched folder and can better determine how to present media. Also, you can make an entity assignment for new file types by adding a registry value instead of adding code. Registering unsupported file types improves performance because Media Library can immediately identify unsupported media in the entity tables without executing additional parsing logic.

See Also

Concepts

Extending Windows Media Library with a Media Parser Plug-In
Prerequisites for Developing Media Library Plug-Ins
Build and Run the Sample Media Parser