Instance Property


The duration of the item.


var duration: CMTime { get }


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

The value of this property will be reported as indefinite 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 player item is AVPlayerItem.Status.readyToPlay.

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

See Also

Inspecting a Player Item

var asset: AVAsset

The asset provided during initialization.

var automaticallyLoadedAssetKeys: [String]

The array of asset keys to be automatically loaded before the player item is ready to play.

var tracks: [AVPlayerItemTrack]

An array of player item track objects.

var status: AVPlayerItem.Status

The status of the player item.

enum AVPlayerItem.Status

The statuses for a player item.

var timebase: CMTimebase?

The timebase information for the item.

var loadedTimeRanges: [NSValue]

An array of time ranges indicating media data that is readily available.

var presentationSize: CGSize

The size at which the visual portion of the item is presented by the player.

var timedMetadata: [AVMetadataItem]?

An array of the most recently encountered timed metadata.

var error: Error?

The error that caused the player item to fail.