iOS Developer Library

Developer

AVFoundation Framework Reference AVPlayerItem Class Reference

Options
Deployment Target:

On This Page
Language:

AVPlayerItem

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.0 and later.

An AVPlayerItem represents the presentation state of an asset that’s played by an AVPlayer object, and lets you observe that state.

An AVPlayerItem object carries a reference to an AVAsset object and presentation settings for that asset, including track enabled state. If you need to inspect the media assets themselves, you should message the AVAsset object itself.

You initialize a player item using an URL (playerItemWithURL: and initWithURL:); the resource types referenced by the URL are returned by the AVURLAsset method audiovisualTypes, which provides the current list of supported files at runtime, along with the playable key of the asset, which reports whether a specific asset instance is playable.

If you want to play an asset more than once within a sequence of items, you must create independent instances of AVPlayerItem for each placement in the player's queue.

The value of player item properties are not valid until the underlying asset is loaded. There are two ways to ensure that the value of duration is accessed only after it becomes available:

  • Wait until the status of the AVPlayerItem is AVPlayerItemStatusReadyToPlay.

  • Use key-value observing and request the initial value. If the initial value is reported as kCMTimeIndefinite, the AVPlayerItem will notify you of the availability of the item's duration via key-value observing as soon as its value becomes known.

If you want information about an item's asset before you enqueue the item for playback, use the AVAsynchronousKeyValueLoading protocol to load the values of the asset properties you need the values of. If you would instead prefer that the information you require become ready while the item is prepared for playback, the AVPlayerItem can provide the data by adding the the desired asset properties to the array passed to the playerItemWithAsset:automaticallyLoadedAssetKeys: or initWithAsset:automaticallyLoadedAssetKeys: methods.

  • asset asset Property

    The underlying asset provided during initialization. (read-only)

    Declaration

    Swift

    var asset: AVAsset! { get }

    Objective-C

    @property(nonatomic, readonly) AVAsset *asset

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • tracks tracks Property

    An array of AVPlayerItemTrack objects. (read-only)

    Declaration

    Swift

    var tracks: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *tracks

    Discussion

    This property can change dynamically during playback.

    You can observe this property using Key-value observing.

    When linked against iOS 7.0 or later, before the underlying tracks have been loaded, the value of this property is an empty array. Use key-value observing to obtain a valid tracks array as soon as it becomes available.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • status status Property

    The status of the player item. (read-only)

    Declaration

    Swift

    var status: AVPlayerItemStatus { get }

    Objective-C

    @property(nonatomic, readonly) AVPlayerItemStatus status

    Discussion

    For example, whether the item is playable. For possible values, see AVPlayerItemStatus.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • duration duration Property

    Indicates the duration of the item. (read-only)

    Declaration

    Swift

    var duration: CMTime { get }

    Objective-C

    @property(nonatomic, readonly) CMTime duration

    Discussion

    Indicates the duration of the item, not considering either its forwardPlaybackEndTime or reversePlaybackEndTime.

    The value of this property will be reported as kCMTimeIndefinite until the duration of the underlying asset has been loaded. There are two ways to ensure that the value of duration is accessed only after it becomes available:

    • Wait until the status of the AVPlayerItem is AVPlayerItemStatusReadyToPlay.

    • Register for key-value observation of the property, requesting the initial value. If the initial value is reported as kCMTimeIndefinite, the AVPlayerItem will notify you of the availability of the item's duration via key-value observing as soon as its value becomes known.

    When linked against iOS 7.0 or later, before the underlying duration has been loaded, the value of this property is kCMTimeIndefinite. Use key-value observing to obtain a valid duration as soon as it becomes available. (Note that the value of duration may remain kCMTimeIndefinite for live streams.)

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.3 and later.

  • timebase timebase Property

    The timebase information for the item. (read-only)

    Declaration

    Swift

    var timebase: CMTimebase! { get }

    Objective-C

    @property(nonatomic, readonly) CMTimebaseRef timebase

    Discussion

    Timebase information is used to synchronize playback of the current item with the master clock. You can use this property to access the timebase information, but you cannot use it to set the time or rate of playback.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • The time ranges of the item that have been loaded. (read-only)

    Declaration

    Swift

    var loadedTimeRanges: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *loadedTimeRanges

    Discussion

    The array contains NSValue objects containing a CMTimeRange value.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The size at which the visual portion of the item is presented by the player. (read-only)

    Declaration

    Swift

    var presentationSize: CGSize { get }

    Objective-C

    @property(nonatomic, readonly) CGSize presentationSize

    Discussion

    You can scale the presentation size to fit within the bounds of a player layer using its videoGravity property. You can also scale the presentation size arbitrarily using the frame property of an AVPlayerLayer object.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The timed metadata played most recently by the media stream. (read-only)

    Declaration

    Swift

    var timedMetadata: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *timedMetadata

    Discussion

    The array contains instances of AVMetadataItem.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • error error Property

    If the receiver's status is AVPlayerItemStatusFailed, this describes the error that caused the failure. (read-only)

    Declaration

    Swift

    var error: NSError! { get }

    Objective-C

    @property(nonatomic, readonly) NSError *error

    Discussion

    The value of this property is an error that describes what caused the receiver to no longer be able to be played.

    If the receiver's status is not AVPlayerItemStatusFailed, the value of this property is nil.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Moves the player’s current item’s current time forward or backward by a specified number of steps.

    Declaration

    Swift

    func stepByCount(_ stepCount: Int)

    Objective-C

    - (void)stepByCount:(NSInteger)stepCount

    Parameters

    stepCount

    The number of steps by which to move.

    A positive number steps forward, a negative number steps backward.

    Discussion

    The size of each step depends on the receiver’s enabled AVPlayerItemTrack objects (see tracks).

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • An array of time ranges within which it is possible to seek. (read-only)

    Declaration

    Swift

    var seekableTimeRanges: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *seekableTimeRanges

    Discussion

    The array contains NSValue objects containing a CMTimeRange value.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Moves the playback cursor to a given date.

    Declaration

    Swift

    func seekToDate(_ date: NSDate!) -> Bool

    Objective-C

    - (BOOL)seekToDate:(NSDate *)date

    Parameters

    date

    The date to which to move the playback cursor.

    Return Value

    YEStrue if the playhead was moved to date, otherwise NOfalse.

    Discussion

    For playback content that is associated with a range of dates, this method moves the playhead to point within that range. This method will fail (return NOfalse) if date is outside the range or if the content is not associated with a range of dates.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Moves the playback cursor to a given time.

    Declaration

    Swift

    func seekToTime(_ time: CMTime)

    Objective-C

    - (void)seekToTime:(CMTime)time

    Parameters

    time

    The time to which to move the playback cursor.

    Discussion

    The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Moves the playback cursor to a given time.

    Declaration

    Swift

    func seekToTime(_ time: CMTime, completionHandler completionHandler: ((Bool) -> Void)!)

    Objective-C

    - (void)seekToTime:(CMTime)time completionHandler:(void (^)(BOOL finished))completionHandler

    Parameters

    time

    The time to which to seek.

    completionHandler

    The block to invoke when the seek operation has either been completed or been interrupted. The block takes one argument:

    finished

    Indicates whether the seek operation completed.

    Discussion

    Use this method to seek to a specified time in the item item and be notified when the operation completes. If the seek request completes without being interrupted (either by another seek request or by any other operation), the completion handler you provide is executed with the finished parameter set to YEStrue.

    If another seek request is already in progress when you call this method, the completion handler for the in-progress seek request is executed immediately with the finished parameter set to NOfalse.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Moves the playback cursor to the time given by the specified date object.

    Declaration

    Swift

    func seekToDate(_ date: NSDate!, completionHandler completionHandler: ((Bool) -> Void)!) -> Bool

    Objective-C

    - (BOOL)seekToDate:(NSDate *)date completionHandler:(void (^)(BOOL finished))completionHandler

    Parameters

    date

    The time to which to seek.

    completionHandler

    The block to invoke when the seek operation has either been completed or been interrupted. The block takes one argument:

    finished

    Indicates whether the seek operation completed.

    Return Value

    YEStrue if the playhead moved to the specified date or NOfalse if it did not.

    Discussion

    Use this method to seek to a specified time in the item item and be notified when the operation completes. If the seek request completes without being interrupted (either by another seek request or by any other operation), the completion handler you provide is executed with the finished parameter set to YEStrue.

    If another seek request is already in progress when you call this method, the completion handler for the in-progress seek request is executed immediately with the finished parameter set to NOfalse.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Moves the playback cursor within a specified time bound.

    Declaration

    Swift

    func seekToTime(_ time: CMTime, toleranceBefore toleranceBefore: CMTime, toleranceAfter toleranceAfter: CMTime)

    Objective-C

    - (void)seekToTime:(CMTime)time toleranceBefore:(CMTime)toleranceBefore toleranceAfter:(CMTime)toleranceAfter

    Parameters

    time

    The time to which you would like to move the playback cursor.

    toleranceBefore

    The tolerance allowed before time.

    toleranceAfter

    The tolerance allowed after time.

    Discussion

    The time seeked to will be within the range [time-beforeTolerance, time+afterTolerance], and may differ from the specified time for efficiency. If you pass kCMTimeZero for both toleranceBefore and toleranceAfter (to request sample accurate seeking), you may incur additional decoding delay.

    Passing kCMTimePositiveInfinity for both toleranceBefore and toleranceAfter is the same as messaging seekToTime: directly.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Moves the playback cursor within a specified time bound.

    Declaration

    Swift

    func seekToTime(_ time: CMTime, toleranceBefore toleranceBefore: CMTime, toleranceAfter toleranceAfter: CMTime, completionHandler completionHandler: ((Bool) -> Void)!)

    Objective-C

    - (void)seekToTime:(CMTime)time toleranceBefore:(CMTime)toleranceBefore toleranceAfter:(CMTime)toleranceAfter completionHandler:(void (^)(BOOL finished))completionHandler

    Parameters

    time

    The time to which to seek.

    toleranceBefore

    The temporal tolerance before time.

    Pass kCMTimeZero to request sample accurate seeking (this may incur additional decoding delay).

    toleranceAfter

    The temporal tolerance after time.

    Pass kCMTimeZero to request sample accurate seeking (this may incur additional decoding delay).

    completionHandler

    The block to invoke when the seek operation has finished.

    Discussion

    Use this method to seek to a specified time for the item.

    The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from time for efficiency.

    Invoking this method with kCMTimePositiveInfinity for toleranceBefore and toleranceAfter is the same as invoking seekToTime:completionHandler: directly.

    Seeking is constrained by the collection of seekable time ranges. If you seek to a time outside all of the seekable ranges the seek will result in a currentTime within the seekable ranges.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Cancel any pending seek requests and invoke the corresponding completion handlers if present.

    Declaration

    Swift

    func cancelPendingSeeks()

    Objective-C

    - (void)cancelPendingSeeks

    Discussion

    Use this method to cancel and release the completion handlers of pending seeks.

    The finished parameter of the completion handlers will be set to NOfalse.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Indicates whether the item will likely play through without stalling (read-only)

    Declaration

    Swift

    var playbackLikelyToKeepUp: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isPlaybackLikelyToKeepUp) BOOL playbackLikelyToKeepUp

    Discussion

    This property communicates a prediction of playability. Factors considered in this prediction include I/O throughput and media decode performance. It is possible for playbackLikelyToKeepUp to indicate NOfalse while the property playbackBufferFull indicates YEStrue. In this event the playback buffer has reached capacity but there isn't the statistical data to support a prediction that playback is likely to keep up in the future. It is up to you to decide whether to continue media playback.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Indicates whether playback has consumed all buffered media and that playback will stall or end. (read-only)

    Declaration

    Swift

    var playbackBufferEmpty: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isPlaybackBufferEmpty) BOOL playbackBufferEmpty

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Indicates whether the internal media buffer is full and that further I/O is suspended. (read-only)

    Declaration

    Swift

    var playbackBufferFull: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isPlaybackBufferFull) BOOL playbackBufferFull

    Discussion

    Despite the playback buffer reaching capacity there might not exist sufficient statistical data to support a playbackLikelyToKeepUp prediction of YEStrue.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • A Boolean value indicating whether the item can be played with a rate of -1.0. (read-only)

    Declaration

    Swift

    var canPlayReverse: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canPlayReverse

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value indicating whether the item can be played at rates greater than 1.0. (read-only)

    Declaration

    Swift

    var canPlayFastForward: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canPlayFastForward

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • A Boolean value indicating whether the item can be played at rates less than –1.0. (read-only)

    Declaration

    Swift

    var canPlayFastReverse: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canPlayFastReverse

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • A Boolean value indicating whether the item can be played at a rate between 0.0 and 1.0. (read-only)

    Declaration

    Swift

    var canPlaySlowForward: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canPlaySlowForward

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value indicating whether the item can be played at a rate between -1.0 and 0.0. (read-only)

    Declaration

    Swift

    var canPlaySlowReverse: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canPlaySlowReverse

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value indicating whether the item supports stepping backward. (read-only)

    Declaration

    Swift

    var canStepBackward: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canStepBackward

    Discussion

    Once the item becomes ready to play, the value of this property does not change. This behavior applies even when boundary conditions, such as when the item’s current time is kCMTimeZero, have been reached.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value indicating whether the item supports stepping forward. (read-only)

    Declaration

    Swift

    var canStepForward: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL canStepForward

    Discussion

    Once the item becomes ready to play, the value of this property does not change. This behavior applies even when boundary conditions, such as when the item’s current time is equal to its end time, have been reached.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Returns the current time of the item.

    Declaration

    Swift

    func currentTime() -> CMTime

    Objective-C

    - (CMTime)currentTime

    Return Value

    The current time of the item.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

    See Also

    – currentDate

  • Returns the current time of the item as an NSDate object.

    Declaration

    Swift

    func currentDate() -> NSDate!

    Objective-C

    - (NSDate *)currentDate

    Return Value

    The current time of the item as an NSDate object, or nil if playback is not mapped to any date.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.3 and later.

    See Also

    – currentTime

  • The time at which forward playback ends.

    Declaration

    Swift

    var forwardPlaybackEndTime: CMTime

    Objective-C

    @property(nonatomic) CMTime forwardPlaybackEndTime

    Discussion

    The value indicated the time at which playback should end when the playback rate is positive (see AVPlayer’s rate property).

    The default value is kCMTimeInvalid, which indicates that no end time for forward playback is specified. In this case, the effective end time for forward playback is the item’s duration.

    The value of this property has no effect on playback when the rate is negative.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The time at which reverse playback ends.

    Declaration

    Swift

    var reversePlaybackEndTime: CMTime

    Objective-C

    @property(nonatomic) CMTime reversePlaybackEndTime

    Discussion

    The value indicated the time at which playback should end when the playback rate is negative (see AVPlayer’s rate property).

    The default value is kCMTimeInvalid, which indicates that no end time for reverse playback is specified. In this case, the effective end time for reverse playback is kCMTimeZero.

    The value of this property has no effect on playback when the rate is positive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • audioMix audioMix Property

    The audio mix parameters to be applied during playback.

    Declaration

    Swift

    @NSCopying var audioMix: AVAudioMix!

    Objective-C

    @property(nonatomic, copy) AVAudioMix *audioMix

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The video composition settings to be applied during playback.

    Declaration

    Swift

    @NSCopying var videoComposition: AVVideoComposition!

    Objective-C

    @property(nonatomic, copy) AVVideoComposition *videoComposition

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • A Boolean value indicating whether the item’s timing follows the displayed video frame when seeking with a video composition.

    Declaration

    Swift

    var seekingWaitsForVideoCompositionRendering: Bool

    Objective-C

    @property(nonatomic) BOOL seekingWaitsForVideoCompositionRendering

    Discussion

    By default, item timing is updated as quickly as possible during seeking. Specifically, the item does not wait for new frames to be rendered when seeking during normal playback. In most situations, the latency between the completion of a seek operation and the display of a video frame at the new time is negligible. However, when video compositions are in use, the processing of video may introduce noticeable latency. Setting the value of this property to YEStrue causes the item’s timing to be updated only after the corresponding video frame has been displayed. For example, this allows an AVSynchronizedLayer object associated with the item to remain in sync with the displayed video.

    This property has no effect on items whose videoComposition property is nil.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • The processing algorithm used to manage audio pitch for scaled audio edits.

    Declaration

    Swift

    var audioTimePitchAlgorithm: String!

    Objective-C

    @property(nonatomic, copy) NSString *audioTimePitchAlgorithm

    Discussion

    The supported constants are defined in Time Pitch Algorithm Settings.

    An NSInvalidArgumentException will be raised if this property is set to a value other than the defined constants.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • The custom video compositor, if any. (read-only)

    Declaration

    Swift

    var customVideoCompositor: AVVideoCompositing! { get }

    Objective-C

    @property(nonatomic, readonly) id< AVVideoCompositing > customVideoCompositor

    Discussion

    The custom video compositor instance that is used during image generation is accessible via this property after the value of AVPlayerItemStatusFailed is set to an AVVideoComposition instance that specifies a custom video compositor class. Any additional communication between the application and that instance of the custom video compositor, if any is required for configuration or other purposes, can only occur once that has happened.

    If the value of AVPlayerItemStatusFailed is changed from an AVVideoComposition that specifies a custom video compositor class to another instance of AVVideoComposition that specifies the same custom video compositor class, the instance of the custom video compositor that was previously created will receive the renderContextChanged: message and remain in use for subsequent image generation.

    This property is nil if there is no video compositor, or if the internal video compositor is in use.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • An array of property keys defined by the asset property. (read-only)

    Declaration

    Swift

    var automaticallyLoadedAssetKeys: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *automaticallyLoadedAssetKeys

    Discussion

    The value of each key in automaticallyLoadedAssetKeys will be automatically be loaded by the asset before the receiver achieves the status AVPlayerItemStatusReadyToPlay; i.e. when the item is ready to play, the value of invoking statusOfValueForKey:error: on the asset property value will be AVKeyValueStatusLoaded. If loading of any of the values fails, the status property of the receiver will change to AVPlayerItemStatusFailed.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • The desired limit, in bits per second, of network bandwidth consumption for this item.

    Declaration

    Swift

    var preferredPeakBitRate: Double

    Objective-C

    @property(nonatomic) double preferredPeakBitRate

    Discussion

    Set preferredPeakBitRate to non-zero to indicate that the player should attempt to limit item playback to that bit rate, expressed in bits per second.

    If network bandwidth consumption cannot be lowered to meet the preferredPeakBitRate, it will be reduced as much as possible while continuing to play the item.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 8.0 and later.

  • Returns an object that represents a snapshot of the network access log.

    Declaration

    Swift

    func accessLog() -> AVPlayerItemAccessLog!

    Objective-C

    - (AVPlayerItemAccessLog *)accessLog

    Return Value

    An object that represents a snapshot of the network access log. The returned value can be nil.

    Discussion

    If the method returns nil, there is no logging information currently available for the player item.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.3 and later.

  • Returns an object that represents a snapshot of the error log.

    Declaration

    Swift

    func errorLog() -> AVPlayerItemErrorLog!

    Objective-C

    - (AVPlayerItemErrorLog *)errorLog

    Return Value

    An object that represents a snapshot of the error log. The returned value can be nil.

    Discussion

    If the method returns nil, there is no logging information currently available for the player item.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.3 and later.

  • Selects the media option described by a specified instance of AVMediaSelectionOption in a given media selection group and deselects all other options in that group.

    Declaration

    Swift

    func selectMediaOption(_ mediaSelectionOption: AVMediaSelectionOption!, inMediaSelectionGroup mediaSelectionGroup: AVMediaSelectionGroup!)

    Objective-C

    - (void)selectMediaOption:(AVMediaSelectionOption *)mediaSelectionOption inMediaSelectionGroup:(AVMediaSelectionGroup *)mediaSelectionGroup

    Parameters

    mediaSelectionOption

    The option to select.

    If the value of the allowsEmptySelection property of mediaSelectionGroup is YEStrue, you can pass nil to deselect all media selection options in the group.

    mediaSelectionGroup

    The media selection group, obtained from the receiver's asset, that contains mediaSelectionOption.

    Discussion

    If mediaSelectionOption isn’t a member of the mediaSelectionGroup, no change in presentation state will result.

    If multiple options within a group meet your criteria for selection according to locale or other considerations, and if these options are otherwise indistinguishable to you according to media characteristics that are meaningful for your application, content is typically authored so that the first available option that meets your criteria is appropriate for selection.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Indicates the media selection option that's currently selected from the specified group.

    Declaration

    Swift

    func selectedMediaOptionInMediaSelectionGroup(_ mediaSelectionGroup: AVMediaSelectionGroup!) -> AVMediaSelectionOption!

    Objective-C

    - (AVMediaSelectionOption *)selectedMediaOptionInMediaSelectionGroup:(AVMediaSelectionGroup *)mediaSelectionGroup

    Parameters

    mediaSelectionGroup

    A media selection group obtained from the player item’s asset.

    Return Value

    An instance of AVMediaSelectionOption that describes the currently selection option in the group.

    Discussion

    If the value of the allowsEmptySelection property of mediaSelectionGroup is YEStrue, the currently selected option in the group may be nil.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Selects the media option in the specified media selection group that best matches the receiver’s automatic selection criteria.

    Declaration

    Swift

    func selectMediaOptionAutomaticallyInMediaSelectionGroup(_ mediaSelectionGroup: AVMediaSelectionGroup!)

    Objective-C

    - (void)selectMediaOptionAutomaticallyInMediaSelectionGroup:(AVMediaSelectionGroup *)mediaSelectionGroup

    Parameters

    mediaSelectionGroup

    The media selection group, obtained from the receiver's asset, that contains the specified option.

    Discussion

    This method has no effect unless the appliesMediaSelectionCriteriaAutomatically property of the associated AVPlayer is YEStrue and unless automatic media selection has previously been overridden by invoking sselectMediaOption:inMediaSelectionGroup:.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • An array of text style rules to apply to subtitles and other legible text.

    Declaration

    Swift

    var textStyleRules: [AnyObject]!

    Objective-C

    @property(nonatomic, copy) NSArray *textStyleRules

    Discussion

    You can use this property to assign an array of AVTextStyleRule objects to the item. Each rule specifies both the style information and the range of text to which that styling should apply.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • outputs outputs Property

    The outputs associated with the item. (read-only)

    Declaration

    Swift

    var outputs: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *outputs

    Discussion

    This property contains the collection of AVPlayerItemOutput objects used to transfer media data to the player object.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Adds the specified player item output object to the receiver.

    Declaration

    Swift

    func addOutput(_ output: AVPlayerItemOutput!)

    Objective-C

    - (void)addOutput:(AVPlayerItemOutput *)output

    Parameters

    output

    The player item output object to associate with the item.

    Discussion

    When you add an AVPlayerItemOutput object to an item, the samples associated with that output object are processed according to the rules for mixing, composing, or excluding content that the AVPlayer object honors for the specific media type. For example, video media is composed according to the instructions provided by the player item’s video composition object and audio media is mixed according to the parameters of its audio mix object.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Removes the specified player item output object from the receiver.

    Declaration

    Swift

    func removeOutput(_ output: AVPlayerItemOutput!)

    Objective-C

    - (void)removeOutput:(AVPlayerItemOutput *)output

    Parameters

    output

    The player item output object to remove.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Constants that represent the status of an item

    Declaration

    Swift

    enum AVPlayerItemStatus : Int { case Unknown case ReadyToPlay case Failed }

    Objective-C

    enum { AVPlayerItemStatusUnknown, AVPlayerItemStatusReadyToPlay, AVPlayerItemStatusFailed }; typedef NSInteger AVPlayerItemStatus;

    Constants

    • Unknown

      AVPlayerItemStatusUnknown

      The item’s status is unknown.

      Available in iOS 4.0 and later.

    • ReadyToPlay

      AVPlayerItemStatusReadyToPlay

      The item is ready to play.

      Available in iOS 4.0 and later.

    • Failed

      AVPlayerItemStatusFailed

      The item cannot be played.

      Available in iOS 4.0 and later.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Key to retrieve information from a notification’s user info dictionary.

    Declaration

    Swift

    let AVPlayerItemFailedToPlayToEndTimeErrorKey: String

    Objective-C

    extern NSString *const AVPlayerItemFailedToPlayToEndTimeErrorKey

    Constants

    • AVPlayerItemFailedToPlayToEndTimeErrorKey

      AVPlayerItemFailedToPlayToEndTimeErrorKey

      The key to retrieve an error object (NSError) from the user info dictionary of an AVPlayerItemTimeJumpedNotification notification.

      Available in iOS 4.3 and later.

  • Posted when the item has played to its end time.

    The notification’s object is the item that finished playing.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Posted when the item failed to play to its end time.

    The notification’s object is the player item that finished playing.

    The user info dictionary contains an error object that describes the problem—see AVPlayerItemFailedToPlayToEndTimeErrorKey.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.3 and later.

  • Posted when the item’s current time has changed discontinuously.

    The notification’s object is the player item.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Posted when some media did not arrive in time to continue playback.

    The notification’s object is the AVPlayerItem instance whose playback was unable to continue because the necessary streaming media wasn’t delivered in a timely fashion over a network. Playback of streaming media continues once a sufficient amount of data is delivered. File-based playback does not continue.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Posted when a new access log entry has been added.

    The notification’s object is the player item. The new log entry is accessible via accessLog.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • Posted when a new error log entry has been added.

    The notification’s object is the player item. The new log entry is accessible via errorLog, respectively.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.