MLMedia class provides an interface for accessing a collection of media objects from various sources. It serves as the initial access point of the Media Library framework.
- macOS 10.9–10.15Deprecated
The media library structure is defined by
MLMedia classes. At the highest level, all content within a media library instance is categorized by media source. Conceptually, a media source represents a single app, such as iTunes or Aperture. Each source contains a hierarchy of media groups that originates from a root group. These groups consist of media objects—individual files containing a piece of media such as a photo, song, or movie. Only one copy of each object exists within a media library instance, but an object can be referenced by multiple groups from a single source. The structure of the group hierarchy is specific to each media source.
A media library is initialized using the
init(options:) method. The options argument to this method serves as a filter. By specifying which folders or sources to include or exclude during load, you can view a particular subset of groups and objects from your collection. All objects provided are thread-safe. For descriptions of possible load options, see Load Options Keys.
The typical and most efficient use case is to create and use one instance of
MLMedia for the lifetime of an app. When the underlying media files and metadata on the user’s system change, the corresponding data model objects (media groups and media objects) are automatically updated and KVO notifications are sent to notify the calling code of any changes. Multiple instances of
MLMedia can be created and used, but their sources, groups, and objects will be independent of those provided by other instances of