Class: AVPlayerItem
Overview
An AVPlayerItem represents the presentation state of an asset that’s played by an AVPlayer object, and lets you observe that state.
Instance Attribute Summary (collapse)
-
- asset
readonly
The underlying asset provided during initialization.
-
- audioMix
The audio mix parameters to be applied during playback.
-
- canPlayFastForward
readonly
A Boolean value indicating whether the item can be played at rates greater than 1.0.
-
- canPlayFastReverse
readonly
A Boolean value indicating whether the item can be played at rates less than –1.0.
-
- canPlayReverse
readonly
A Boolean value indicating whether the item can be played with a rate of -1.0.
-
- canPlaySlowForward
readonly
A Boolean value indicating whether the item can be played at a rate between 0.0 and 1.0.
-
- canPlaySlowReverse
readonly
A Boolean value indicating whether the item can be played at a rate between -1.0 and 0.0.
-
- canStepBackward
readonly
A Boolean value indicating whether the item supports stepping backward.
-
- canStepForward
readonly
A Boolean value indicating whether the item supports stepping forward.
-
- duration
readonly
Indicates the duration of the item.
-
- error
readonly
If the receiver's status is AVPlayerItemStatusFailed, this describes the error that caused the failure.
-
- forwardPlaybackEndTime
The time at which forward playback ends.
-
- loadedTimeRanges
readonly
The time ranges of the item that have been loaded.
-
- outputs
readonly
The outputs associated with the item.
-
- playbackBufferEmpty
readonly
Indicates whether playback has consumed all buffered media and that playback will stall or end.
-
- playbackBufferFull
readonly
Indicates whether the internal media buffer is full and that further I/O is suspended.
-
- playbackLikelyToKeepUp
readonly
Indicates whether the item will likely play through without stalling (read-only) This property communicates a prediction of playability.
-
- presentationSize
readonly
The size at which the visual portion of the item is presented by the player.
-
- reversePlaybackEndTime
The time at which reverse playback ends.
-
- seekableTimeRanges
readonly
An array of time ranges within which it is possible to seek.
-
- seekingWaitsForVideoCompositionRendering
A Boolean value indicating whether the item’s timing follows the displayed video frame when seeking with a video composition.
-
- status
readonly
The status of the player item.
-
- textStyleRules
An array of text style rules to apply to subtitles and other legible text.
-
- timebase
readonly
The timebase information for the item.
-
- timedMetadata
readonly
The timed metadata played most recently by the media stream.
-
- tracks
readonly
An array of AVPlayerItemTrack objects.
-
- videoComposition
The video composition settings to be applied during playback.
Class Method Summary (collapse)
-
+ playerItemWithAsset:
Returns a new player item for a given asset.
-
+ playerItemWithURL:
Returns a new player item, prepared to use a given URL.
Instance Method Summary (collapse)
-
- accessLog
Returns an object that represents a snapshot of the network access log.
-
- addOutput:
Adds the specified player item output object to the receiver.
-
- cancelPendingSeeks
Cancel any pending seek requests and invoke the corresponding completion handlers if present.
-
- currentDate
Returns the current time of the item as an NSDate object.
-
- currentTime
Returns the current time of the item.
-
- errorLog
Returns an object that represents a snapshot of the error log.
-
- initWithAsset:
Initializes a new player item for a given asset.
-
- initWithURL:
Prepares a player item with a given URL.
-
- removeOutput:
Removes the specified player item output object from the receiver.
-
- seekToDate:
Moves the playback cursor to a given date.
-
- seekToDate:completionHandler:
Moves the playback cursor to the time given by the specified date object.
-
- seekToTime:
Moves the playback cursor to a given time.
-
- seekToTime:completionHandler:
Moves the playback cursor to a given time.
-
- seekToTime:toleranceBefore:toleranceAfter:
Moves the playback cursor within a specified time bound.
-
- seekToTime:toleranceBefore:toleranceAfter:completionHandler:
Moves the playback cursor within a specified time bound.
-
- selectedMediaOptionInMediaSelectionGroup:
Indicates the media selection option that's currently selected from the specified group.
-
- selectMediaOption:inMediaSelectionGroup:
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.
-
- stepByCount:
Moves the player’s current item’s current time forward or backward by a specified number of steps.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (AVAsset) asset (readonly)
The underlying asset provided during initialization. (read-only)
- (AVAudioMix) audioMix
The audio mix parameters to be applied during playback.
- (Boolean) canPlayFastForward (readonly)
A Boolean value indicating whether the item can be played at rates greater than 1.0. (read-only)
- (Boolean) canPlayFastReverse (readonly)
A Boolean value indicating whether the item can be played at rates less than –1.0. (read-only)
- (Boolean) canPlayReverse (readonly)
A Boolean value indicating whether the item can be played with a rate of -1.0. (read-only)
- (Boolean) canPlaySlowForward (readonly)
A Boolean value indicating whether the item can be played at a rate between 0.0 and 1.0. (read-only)
- (Boolean) canPlaySlowReverse (readonly)
A Boolean value indicating whether the item can be played at a rate between -1.0 and 0.0. (read-only)
- (Boolean) canStepBackward (readonly)
A Boolean value indicating whether the item supports stepping backward. (read-only) 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.
- (Boolean) canStepForward (readonly)
A Boolean value indicating whether the item supports stepping forward. (read-only) 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.
- (CMTime) duration (readonly)
Indicates the duration of the item. (read-only) Indicates the duration of the item, not considering either its forwardPlaybackEndTime or reversePlaybackEndTime.
- (NSError) error (readonly)
If the receiver's status is AVPlayerItemStatusFailed, this describes the error that caused the failure. (read-only) 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.
- (CMTime) forwardPlaybackEndTime
The time at which forward playback ends. 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.
- (Array) loadedTimeRanges (readonly)
The time ranges of the item that have been loaded. (read-only) The array contains NSValue objects containing a CMTimeRange value.
- (Array) outputs (readonly)
The outputs associated with the item. (read-only) This property contains the collection of AVPlayerItemOutput objects used to transfer media data to the player object.
- (Boolean) playbackBufferEmpty (readonly)
Indicates whether playback has consumed all buffered media and that playback will stall or end. (read-only)
- (Boolean) playbackBufferFull (readonly)
Indicates whether the internal media buffer is full and that further I/O is suspended. (read-only) Despite the playback buffer reaching capacity there might not exist sufficient statistical data to support a playbackLikelyToKeepUp prediction of YES.
- (Boolean) playbackLikelyToKeepUp (readonly)
Indicates whether the item will likely play through without stalling (read-only) 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 NO while the property playbackBufferFull indicates YES. 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.
- (CGSize) presentationSize (readonly)
The size at which the visual portion of the item is presented by the player. (read-only) 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.
- (CMTime) reversePlaybackEndTime
The time at which reverse playback ends. 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.
- (Array) seekableTimeRanges (readonly)
An array of time ranges within which it is possible to seek. (read-only) The array contains NSValue objects containing a CMTimeRange value.
- (Boolean) seekingWaitsForVideoCompositionRendering
A Boolean value indicating whether the item’s timing follows the displayed video frame when seeking with a video composition. 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 YES 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.
- (AVPlayerItemStatus) status (readonly)
The status of the player item. (read-only) For example, whether the item is playable. For possible values, see “AVPlayerItemStatus.”
- (Array) textStyleRules
An array of text style rules to apply to subtitles and other legible text. 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.
- (__attribute__((NSObject)) CMTimebaseRef) timebase (readonly)
The timebase information for the item. (read-only) 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.
- (Array) timedMetadata (readonly)
The timed metadata played most recently by the media stream. (read-only) The array contains instances of AVMetadataItem.
- (Array) tracks (readonly)
An array of AVPlayerItemTrack objects. (read-only) This property can change dynamically during playback.You can observe this property using key-value observing.
- (Object) videoComposition
The video composition settings to be applied during playback.
Class Method Details
+ (AVPlayerItem) playerItemWithAsset(asset)
Returns a new player item for a given asset.
+ (AVPlayerItem) playerItemWithURL(URL)
Returns a new player item, prepared to use a given URL.
Instance Method Details
- (AVPlayerItemAccessLog) accessLog
Returns an object that represents a snapshot of the network access log. If the method returns nil, there is no logging information currently available for the player item.
- (Object) addOutput(output)
Adds the specified player item output object to the receiver. 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.
- (Object) cancelPendingSeeks
Cancel any pending seek requests and invoke the corresponding completion handlers if present. Use this method to cancel and release the completion handlers of pending seeks.The finished parameter of the completion handlers will be set to NO.
- (CMTime) currentTime
Returns the current time of the item.
- (AVPlayerItemErrorLog) errorLog
Returns an object that represents a snapshot of the error log. If the method returns nil, there is no logging information currently available for the player item.
- (Object) initWithAsset(asset)
Initializes a new player item for a given asset.
- (Object) initWithURL(URL)
Prepares a player item with a given URL.
- (Object) removeOutput(output)
Removes the specified player item output object from the receiver.
- (Boolean) seekToDate(date)
Moves the playback cursor to a given date. 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.
- (Boolean) seekToDate(date, completionHandler:completionHandler)
Moves the playback cursor to the time given by the specified date object. 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 YES. 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 NO.
- (Object) seekToTime(time)
Moves the playback cursor to a given time. The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:.
- (Object) seekToTime(time, completionHandler:completionHandler)
Moves the playback cursor to a given time. 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 YES. 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 NO.
- (Object) seekToTime(time, toleranceBefore:toleranceBefore, toleranceAfter:toleranceAfter)
Moves the playback cursor within a specified time bound. 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.
- (Object) seekToTime(time, toleranceBefore:toleranceBefore, toleranceAfter:toleranceAfter, completionHandler:completionHandler)
Moves the playback cursor within a specified time bound. 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.
- (AVMediaSelectionOption) selectedMediaOptionInMediaSelectionGroup(mediaSelectionGroup)
Indicates the media selection option that's currently selected from the specified group. If the value of the allowsEmptySelection property of mediaSelectionGroup is YES, the currently selected option in the group may be nil.
- (Object) selectMediaOption(mediaSelectionOption, inMediaSelectionGroup:mediaSelectionGroup)
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. 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.
- (Object) stepByCount(stepCount)
Moves the player’s current item’s current time forward or backward by a specified number of steps. The size of each step depends on the receiver’s enabled AVPlayerItemTrack objects (see tracks).