Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AVFoundation.framework |
Availability | Available in iOS 4.0 and later. |
Declared in | AVPlayerItem.h |
An AVPlayerItem
represents the presentation state of an asset that’s played by an AVPlayer
object, and lets you observe that state.
A 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 can initialize a player item using an URL (playerItemWithURL:
and initWithURL:
); the resource types referenced by the URL may include, but aren't necessarily limited to, those with the following corresponding UTIs:
kUTTypeQuickTimeMovie
, (.mov, .qt)
kUTTypeMPEG4
(.mp4)
@"public.3gpp"
(.3gp, .3gpp)
kUTTypeMPEG4Audio
(.m4a)
@"com.apple.coreaudio-format"
(.caf)
@"com.microsoft.waveform-audio"
(.wav)
@"public.aiff-audio"
(.aif)
@"public.aifc-audio"
(also .aif)
@"org.3gpp.adaptive-multi-rate-audio"
(.amr)
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.
asset
property
tracks
property
status
property
loadedTimeRanges
property
presentationSize
property
timedMetadata
property
seekableTimeRanges
property
error
property
playbackLikelyToKeepUp
property
playbackBufferEmpty
property
playbackBufferFull
property
– currentTime
forwardPlaybackEndTime
property
reversePlaybackEndTime
property
audioMix
property
videoComposition
property
For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.
The underlying asset provided during initialization. (read-only)
@property(nonatomic, readonly) AVAsset *asset
AVPlayerItem.h
The audio mix parameters to be applied during playback.
@property(nonatomic, copy) AVAudioMix *audioMix
AVPlayerItem.h
If the receiver's status is AVPlayerItemStatusFailed
, this describes the error that caused the failure. (read-only)
@property(nonatomic, readonly) NSError *error
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
.
AVPlayerItem.h
The time at which forward playback ends.
@property(nonatomic) CMTime forwardPlaybackEndTime
AVPlayerItem.h
The time ranges of the item that have been loaded. (read-only)
@property(nonatomic, readonly) NSArray *loadedTimeRanges
The array contains NSValue
objects containing a CMTimeRange
value.
AVPlayerItem.h
Indicates whether playback has consumed all buffered media and that playback will stall or end. (read-only)
@property(nonatomic, readonly, getter=isPlaybackBufferEmpty) BOOL playbackBufferEmpty
AVPlayerItem.h
Indicates whether the internal media buffer is full and that further I/O is suspended. (read-only)
@property(nonatomic, readonly, getter=isPlaybackBufferFull) BOOL playbackBufferFull
AVPlayerItem.h
Indicates whether the item will likely play through without stalling (read-only)
@property(nonatomic, readonly, getter=isPlaybackLikelyToKeepUp) BOOL playbackLikelyToKeepUp
AVPlayerItem.h
The size at which the visual portion of the item is presented by the player. (read-only)
@property (nonatomic, readonly) CGSize presentationSize;
You can scale the presentation size to fit within the bounds of a player layer using its videoGravity
property.
AVPlayerItem.h
The time at which reverse playback ends.
@property(nonatomic) CMTime reversePlaybackEndTime
AVPlayerItem.h
(read-only)
@property(nonatomic, readonly) NSArray *seekableTimeRanges
The array contains NSValue
objects containing a CMTimeRange
value.
AVPlayerItem.h
The status of the player item. (read-only)
@property(nonatomic, readonly) AVPlayerItemStatus status
For example, whether the item is playable. For possible values, see “AVPlayerItemStatus.”
AVPlayerItem.h
The timed metadata played most recently by the media stream. (read-only)
@property(nonatomic, readonly) NSArray *timedMetadata
The array contains instances of AVMetadataItem
.
AVPlayerItem.h
An array of AVPlayerItemTrack
objects. (read-only)
@property(nonatomic, readonly) NSArray *tracks
This property can change dynamically during playback. You can observe it using key-value observing.
AVPlayerItem.h
The video composition settings to be applied during playback.
@property(nonatomic, copy) AVVideoComposition *videoComposition
AVPlayerItem.h
Returns a new player item for a given asset.
+ (AVPlayerItem *)playerItemWithAsset:(AVAsset *)asset
An asset to play.
A new player item, initialized to play asset.
AVPlayerItem.h
Returns a new player item, prepared to use a given URL.
+ (AVPlayerItem *)playerItemWithURL:(NSURL *)URL
An URL.
A new player item, prepared to use URL.
This method immediately returns the item, but with the status AVPlayerItemStatusUnknown
.
If the URL contains valid data that can be used by the player item, the status later changes to AVPlayerItemStatusReadyToPlay
.
If the URL contains no valid data or otherwise can't be used by the player item, the status later changes to AVPlayerItemStatusFailed
.
AVPlayerItem.h
Returns the current time of the item.
- (CMTime)currentTime
The current time of the item.
AVPlayerItem.h
Initializes a new player item for a given asset.
- (id)initWithAsset:(AVAsset *)asset
An asset to play.
The receiver, initialized to play asset.
AVPlayerItem.h
Prepares a player item with a given URL.
- (id)initWithURL:(NSURL *)URL
An URL.
The receiver, prepared to use URL.
This method immediately returns the item, but with the status AVPlayerItemStatusUnknown
.
If the URL contains valid data that can be used by the player item, the status later changes to AVPlayerItemStatusReadyToPlay
.
If the URL contains no valid data or otherwise can't be used by the player item, the status later changes to AVPlayerItemStatusFailed
.
AVPlayerItem.h
Moves the playback cursor to a given date.
- (BOOL)seekToDate:(NSDate *)date
The date to which to move the playback cursor.
YES
if the playhead was moved to date, otherwise NO
.
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 NO
) if date is outside the range or if the content is not associated with a range of dates.
AVPlayerItem.h
Moves the playback cursor to a given time.
- (void)seekToTime:(CMTime)time
The time to which to move the playback cursor.
The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:
.
AVPlayerItem.h
Moves the playback cursor within a specified time bound.
- (void)seekToTime:(CMTime)time toleranceBefore:(CMTime)toleranceBefore toleranceAfter:(CMTime)toleranceAfter
The time to which you would like to move the playback cursor.
The tolerance allowed before time.
The tolerance allowed after time.
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.
AVPlayerItem.h
Moves the player’s current item’s current time forward or backward by a specified number of steps.
- (void)stepByCount:(NSInteger)stepCount
The number of steps by which to move.
A positive number steps forward, a negative number steps backward.
The size of each step depends on the receiver’s enabled AVPlayerItemTrack
objects (see tracks
).
AVPlayerItem.h
Constants that represent the status of an item
enum { AVPlayerItemStatusUnknown, AVPlayerItemStatusReadyToPlay, AVPlayerItemStatusFailed }; typedef NSInteger AVPlayerItemStatus;
AVPlayerItemStatusUnknown
The item’s status is unknown.
Available in iOS 4.0 and later.
Declared in AVPlayerItem.h
.
AVPlayerItemStatusReadyToPlay
The item is ready to play.
Available in iOS 4.0 and later.
Declared in AVPlayerItem.h
.
AVPlayerItemStatusFailed
The item cannot be played.
Available in iOS 4.0 and later.
Declared in AVPlayerItem.h
.
Posted when the item has played to its end time.
The notification’s object is the item that finished playing.
Important: This notification may be posted on a different thread than the one on which the observer was registered.
AVPlayerItem.h
Last updated: 2010-05-15