<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.9.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "MediaLibrary",
  "identifier" : "/documentation/MediaLibrary/MLMediaSource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Library"
    ],
    "preciseIdentifier" : "c:objc(cs)MLMediaSource"
  },
  "title" : "MLMediaSource"
}
-->

# MLMediaSource

The `MLMediaSource` class identifies a specific provider of media. Conceptually, a media source respresents a single app, such as iTunes or Aperture. Each media source contains multiple groups of media objects—individual files containing a piece of media such as a photo, song, or movie.

```
class MLMediaSource
```

## Overview

The structure of the group hierarchy is specific to each media source, but all sources have certain commonalities. For example, every source has a single root media group, which contains all groups and objects within that source. It is the highest-level parent group in the hierarchy and each of its descendant groups contains its own subgroups and their objects. All groups have a reference to their parent within the hierarchy. A group with no descendants contains only its own objects. If a media group does not contain any objects, it is not visible in the hierarchy.

Every media source has a unique media source identifier within a single media library instance. For a list of possible media source identifiers, see [Media Source Identifiers](/documentation/MediaLibrary/media-source-identifiers).

All `MLMediaSource` properties are read-only, so this information can be accessed but not altered.

## Topics

### Identifying the Source

[`mediaSourceIdentifier`](/documentation/MediaLibrary/MLMediaSource/mediaSourceIdentifier)

A unique identifier for the media source.

[`mediaLibrary`](/documentation/MediaLibrary/MLMediaSource/mediaLibrary)

A pointer to the media library instance that loaded this media source.

### Accessing Source Attributes

[`attributes`](/documentation/MediaLibrary/MLMediaSource/attributes)

A list of attributes describing the media source.

### Accessing the Root Media Group

[`rootMediaGroup`](/documentation/MediaLibrary/MLMediaSource/rootMediaGroup)

The base media group in the media source that contains all other groups within the source as descendant elements.

### Accessing Media

[`mediaGroup(forIdentifier:)`](/documentation/MediaLibrary/MLMediaSource/mediaGroup(forIdentifier:))

Returns the media group with the specified identifier.

[`mediaGroups(forIdentifiers:)`](/documentation/MediaLibrary/MLMediaSource/mediaGroups(forIdentifiers:))

Returns the media groups with the specified identifiers.

[`mediaObject(forIdentifier:)`](/documentation/MediaLibrary/MLMediaSource/mediaObject(forIdentifier:))

Returns the media object with the specified identifier.

[`mediaObjects(forIdentifiers:)`](/documentation/MediaLibrary/MLMediaSource/mediaObjects(forIdentifiers:))

Returns the media objects with the specified identifiers.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)