The MLMediaObject class describes a single media file, such as a photo, song, or movie. Each media object contains basic metadata including a name, media type, URL, and so on. Additional information about each object is stored in its list of attributes. For a list of possible object attribute keys, see Media Object Attribute Keys.


class MLMediaObject : NSObject


A media object belongs to a single media source but can be referenced by several groups within that source. In other words, an object can appear in multiple places in the group hierarchy under a single media source. In iTunes, a movie that was purchased through the iTunes Store is referenced by both the Purchased playlist and the Movies playlist. If a user adds the movie to his own playlist, the group respresenting that playlist will also reference the movie. All three groups reference the same media object.

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


Identifying the Object

var identifier: String

An identifier for the media object.

var mediaSourceIdentifier: String

An identifier for the source that loaded the media object.

var mediaLibrary: MLMediaLibrary?

A pointer to the media library instance that loaded the media object’s source.

Accessing Object Attributes

var attributes: [String : Any]

A dictionary of attributes describing the media object.

var mediaType: MLMediaType

The media object’s type of media (image, audio, or movie).

var contentType: String?

The UTI associated with the media object.

var name: String?

The name of the media object.

var url: URL?

The location of the media object.

var originalURL: URL?

The location of the original media object, if url is not the original (master).

var fileSize: Int

The size, in bytes, of the media object.

var modificationDate: Date?

The date and time when the media object was last altered.

var thumbnailURL: URL?

The location of the media object’s thumbnail image.

var artworkImage: NSImage?

Album artwork associated with the media object.


Inherits From

Conforms To