Class: AVPlayerItem

Inherits:
NSObject show all

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)

Class Method Summary (collapse)

Instance Method Summary (collapse)

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)

Returns:

- (AVAudioMix) audioMix

The audio mix parameters to be applied during playback.

Returns:

- (Boolean) canPlayFastForward (readonly)

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

Returns:

  • (Boolean)

- (Boolean) canPlayFastReverse (readonly)

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

Returns:

  • (Boolean)

- (Boolean) canPlayReverse (readonly)

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

Returns:

  • (Boolean)

- (Boolean) canPlaySlowForward (readonly)

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

Returns:

  • (Boolean)

- (Boolean) canPlaySlowReverse (readonly)

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

Returns:

  • (Boolean)

- (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.

Returns:

  • (Boolean)

- (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.

Returns:

  • (Boolean)

- (CMTime) duration (readonly)

Indicates the duration of the item. (read-only) Indicates the duration of the item, not considering either its forwardPlaybackEndTime or reversePlaybackEndTime.

Returns:

  • (CMTime)

- (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.

Returns:

- (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.

Returns:

  • (CMTime)

- (Array) loadedTimeRanges (readonly)

The time ranges of the item that have been loaded. (read-only) The array contains NSValue objects containing a CMTimeRange value.

Returns:

- (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.

Returns:

- (Boolean) playbackBufferEmpty (readonly)

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

Returns:

  • (Boolean)

- (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.

Returns:

  • (Boolean)

- (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.

Returns:

  • (Boolean)

- (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.

Returns:

- (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.

Returns:

  • (CMTime)

- (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.

Returns:

- (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.

Returns:

  • (Boolean)

- (AVPlayerItemStatus) status (readonly)

The status of the player item. (read-only) For example, whether the item is playable. For possible values, see “AVPlayerItemStatus.”

Returns:

  • (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.

Returns:

- (__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.

Returns:

  • (__attribute__((NSObject)) CMTimebaseRef)

- (Array) timedMetadata (readonly)

The timed metadata played most recently by the media stream. (read-only) The array contains instances of AVMetadataItem.

Returns:

- (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.

Returns:

- (Object) videoComposition

The video composition settings to be applied during playback.

Returns:

Class Method Details

+ (AVPlayerItem) playerItemWithAsset(asset)

Returns a new player item for a given asset.

Parameters:

  • asset (AVAsset)

    An asset to play.

Returns:

  • (AVPlayerItem)

    A new player item, initialized to play asset.

+ (AVPlayerItem) playerItemWithURL(URL)

Returns a new player item, prepared to use a given URL.

Parameters:

  • URL (NSURL)

    An URL.

Returns:

  • (AVPlayerItem)

    A new player item, prepared to use 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.

Returns:

  • (AVPlayerItemAccessLog)

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

- (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.

Parameters:

  • output (AVPlayerItemOutput)

    The player item output object to associate with the item.

Returns:

- (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.

Returns:

- (NSDate) currentDate

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

Returns:

  • (NSDate)

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

- (CMTime) currentTime

Returns the current time of the item.

Returns:

  • (CMTime)

    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.

Returns:

  • (AVPlayerItemErrorLog)

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

- (Object) initWithAsset(asset)

Initializes a new player item for a given asset.

Parameters:

  • asset (AVAsset)

    An asset to play.

Returns:

  • (Object)

    The receiver, initialized to play asset.

- (Object) initWithURL(URL)

Prepares a player item with a given URL.

Parameters:

  • URL (NSURL)

    An URL.

Returns:

  • (Object)

    The receiver, prepared to use URL.

- (Object) removeOutput(output)

Removes the specified player item output object from the receiver.

Parameters:

Returns:

- (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.

Parameters:

  • date (NSDate)

    The date to which to move the playback cursor.

Returns:

  • (Boolean)

    YES if the playhead was moved to date, otherwise NO.

- (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.

Parameters:

  • date (NSDate)

    The time to which to seek.

  • completionHandler (Object)

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

  • finished (BOOL finished)

    Indicates whether the seek operation completed.

Returns:

  • (Boolean)

    YES if the playhead moved to the specified date or NO if it did not.

- (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:.

Parameters:

  • time (CMTime)

    The time to which to move the playback cursor.

Returns:

- (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.

Parameters:

  • time (CMTime)

    The time to which to seek.

  • completionHandler (Object)

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

  • finished (BOOL finished)

    Indicates whether the seek operation completed.

Returns:

- (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.

Parameters:

  • time (CMTime)

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

  • toleranceBefore (CMTime)

    The tolerance allowed before time.

  • toleranceAfter (CMTime)

    The tolerance allowed after time.

Returns:

- (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.

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.

Returns:

- (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.

Parameters:

  • mediaSelectionGroup (AVMediaSelectionGroup)

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

Returns:

- (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.

Parameters:

  • mediaSelectionOption (AVMediaSelectionOption)

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

  • mediaSelectionGroup (AVMediaSelectionGroup)

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

Returns:

- (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).

Parameters:

  • stepCount (Integer)

    The number of steps by which to move.A positive number steps forward, a negative number steps backward.

Returns: