Mac Developer Library

Developer

MediaLibrary Framework Reference MLMediaSource Class Reference

Options
Deployment Target:

On This Page
Language:

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. More...

Inheritance


Conforms To


Import Statement


import MediaLibrary @import MediaLibrary;

Availability


Available in OS X v10.9 and later.
  • A unique identifier for the media source. (read-only)

    Declaration

    Swift

    var mediaSourceIdentifier: String! { get }

    Objective-C

    @property(readonly, copy) NSString *mediaSourceIdentifier

    Discussion

    For a list of possible media source identifiers, see Media Source Identifiers.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A pointer to the media library instance that loaded this media source. (read-only)

    Declaration

    Swift

    unowned(unsafe) var mediaLibrary: MLMediaLibrary! { get }

    Objective-C

    @property(readonly, assign) MLMediaLibrary *mediaLibrary

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • A list of attributes describing the media source. (read-only)

    Declaration

    Swift

    var attributes: [NSObject : AnyObject]! { get }

    Objective-C

    @property(readonly, copy) NSDictionary *attributes

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • The base media group in the media source that contains all other groups within the source as descendant elements. (read-only)

    Declaration

    Swift

    var rootMediaGroup: MLMediaGroup! { get }

    Objective-C

    @property(readonly, retain) MLMediaGroup *rootMediaGroup

    Discussion

    This accessor property is nonblocking. If there is no data yet, it returns nil and automatically triggers an internal asynchronous request. When data arrives, a KVO notification is sent via the main thread.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • Returns the media group with the specified identifier.

    Declaration

    Swift

    func mediaGroupForIdentifier(_ mediaGroupIdentifier: String!) -> MLMediaGroup!

    Objective-C

    - (MLMediaGroup *)mediaGroupForIdentifier:(NSString *)mediaGroupIdentifier

    Parameters

    mediaGroupIdentifier

    The media group identifier to search for in the source.

    Discussion

    The media source must have finished loading before this method returns valid data. Specifically, the root media group must be available before the lookup methods will succeed. Otherwise, the return value is undefined.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • Returns the media groups with the specified identifiers.

    Declaration

    Swift

    func mediaGroupsForIdentifiers(_ mediaGroupIdentifiers: [AnyObject]!) -> [NSObject : AnyObject]!

    Objective-C

    - (NSDictionary *)mediaGroupsForIdentifiers:(NSArray *)mediaGroupIdentifiers

    Parameters

    mediaGroupIdentifiers

    An array of media group identifiers to search for in the source.

    Return Value

    A dictionary of media groups matching the specified identifiers.

    Discussion

    The media source must have finished loading before this method returns valid data. Specifically, the root media group must be available before the lookup methods will succeed. Otherwise, the return value is undefined.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • Returns the media object with the specified identifier.

    Declaration

    Swift

    func mediaObjectForIdentifier(_ mediaObjectIdentifier: String!) -> MLMediaObject!

    Objective-C

    - (MLMediaObject *)mediaObjectForIdentifier:(NSString *)mediaObjectIdentifier

    Parameters

    mediaObjectIdentifier

    The media object identifier to search for in the media source.

    Discussion

    The media source must have finished loading before this method returns valid data. Specifically, the root media group must be available before the lookup methods will succeed. Otherwise, the return value is undefined.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.

  • Returns the media objects with the specified identifiers.

    Declaration

    Swift

    func mediaObjectsForIdentifiers(_ mediaObjectIdentifiers: [AnyObject]!) -> [NSObject : AnyObject]!

    Objective-C

    - (NSDictionary *)mediaObjectsForIdentifiers:(NSArray *)mediaObjectIdentifiers

    Parameters

    mediaObjectIdentifiers

    An array of media object identifiers to search for in the source.

    Return Value

    A dictionary of media objects matching the specified identifiers.

    Discussion

    The media source must have finished loading before this method returns valid data. Specifically, the root media group must be available before the lookup methods will succeed. Otherwise, the return value is undefined.

    Import Statement

    import MediaLibrary

    Availability

    Available in OS X v10.9 and later.