iOS Developer Library

Developer

MediaPlayer Framework Reference MPContentItem Class Reference

Options
Deployment Target:

On This Page
Language:

MPContentItem

Inheritance


Conforms To


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 7.1 and later.

An MPContentItem object contains the information for a particular media item. An MPContentItem object can represent any media item—for example, a song, movie, radio station, or podcast episode. The information stored in an MPContentItem is consumed by the media player and displayed to the user.

Update an MPContentItem object by changing its properties during runtime or by creating a new MPContentItem object with new property values, but with the same identifier as the MPContentItem object to be changed. Use the beginUpdates and endUpdates methods found in MPPlayableContentManager to update several MPContentItem objects at once.

  • init(identifier:) - initWithIdentifier: Designated Initializer

    Sets the identifier for a media item.

    Declaration

    Swift

    init!(identifier identifier: String!)

    Objective-C

    - (instancetype)initWithIdentifier:(NSString *)identifier

    Parameters

    identifier

    A unique identifier for the content item.

    Return Value

    The created MPContentItem object.

    Discussion

    Each media item identifier must be unique. The use of nonunique identifiers can prevent media items from updating properly. Create a new identifier when creating an MPContentItem object.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • artwork artwork Property

    A single image that is associated with the media item.

    Declaration

    Swift

    var artwork: MPMediaItemArtwork!

    Objective-C

    @property(nonatomic, strong) MPMediaItemArtwork *artwork

    Discussion

    An image that is displayed with the media item. A song would have an album cover image, whereas a movie could have a movie poster image associated with it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • container container Property

    Determines if a media item is container of other items.

    Declaration

    Swift

    var container: Bool

    Objective-C

    @property(nonatomic, assign, getter=isContainer) BOOL container

    Discussion

    When set to TRUE, the designated content item is identified as being able to contain other content items. For example, an album is a container that holds multiple songs.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • The unique identifier for the media item. (read-only)

    Declaration

    Swift

    var identifier: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *identifier

    Discussion

    All media items must have a unique identifier. Identifiers must be unique so that Media Player can properly update existing media items or add new media items. Media items will not update properly if multiple media items have the same identifier.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • playable playable Property

    Determines if a media item is able to be played.

    Declaration

    Swift

    var playable: Bool

    Objective-C

    @property(nonatomic, assign, getter=isPlayable) BOOL playable

    Discussion

    When set to TRUE, the designated content item is able to be played. Containers and individual content items can be set to playable. For example, a playlist with multiple songs in it. The playlist is a container that can be played, or the user could choose a song from inside of the playlist.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • The amount of content that has been played for the media item.

    Declaration

    Swift

    var playbackProgress: Float

    Objective-C

    @property(nonatomic, assign) float playbackProgress

    Discussion

    The playbackProgress property uses the values from 0.0 to 1.0. The value 0.0 indicates that the media item has not been viewed, while 1.0 indicates that the media item has been completely played. This property’s default, –1.0 indicates that no progress indicator is shown. The progress indicator is shown automatically if the playbackProgress property has a valid value and the app responds affirmatively to the childItemsDisplayPlaybackProgressAtIndexPath: method.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • subtitle subtitle Property

    A secondary designator for the media item.

    Declaration

    Swift

    var subtitle: String!

    Objective-C

    @property(nonatomic, copy) NSString *subtitle

    Discussion

    A subtitle is another public designator for the media item. For a song track, the subtitle is often the artist or album name.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • title title Property

    The public name of the media item.

    Declaration

    Swift

    var title: String!

    Objective-C

    @property(nonatomic, copy) NSString *title

    Discussion

    The main public designation of a media item is its title. For example, for a music track the title would be the song title. If the media item is a podcast, the title would be the episode name of a particular podcast.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.