Technical Q&A QA1772

How to determine whether an AVPlayerItem can be played at rates greater than 1.0

Q:  I’m using the AVPlayerItem.canPlayFastForward property to find out if an AVPlayerItem can be played at rates greater than 1.0, but it always returns NO. Under what conditions does AVPlayerItem.canPlayFastForward return YES?

A: An AVPlayerItem whose status property equals AVPlayerItemStatusReadyToPlay can be played at rates between 1.0 and 2.0, inclusive, even if AVPlayerItem.canPlayFastForward is NO. AVPlayerItem.canPlayFastForward indicates whether the item can be played at rates greater than 2.0.

The value of the AVPlayerItem.canPlayFastForward property is always reported as NO until the AVPlayerItem.status property changes to AVPlayerItemStatusReadyToPlay. If the AVPlayerItem isn’t prepared to play at all, it certainly can’t play fast.

If the test you are performing is similar to Listing 1 or Listing 2:

Listing 1  Obtaining the value of AVPlayerItem.canPlayFastForward (Swift).

import AVFoundation
 
let anAsset = AVAsset(URL: <#A URL#>)
let playerItem = AVPlayerItem(asset: anAsset)
let canPlayFastForward = playerItem.canPlayFastForward

Listing 2  Obtaining the value of AVPlayerItem.canPlayFastForward (Objective-C).

#import <AVFoundation/AVFoundation.h>
 
AVAsset *asset = [AVAsset assetWithURL:<#A URL>];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
BOOL canPlayFastForward = [playerItem canPlayFastForward];

then the AVPlayerItem.canPlayFastForward property will always be NO.

AVPlayerItem objects are dynamic. The value of AVPlayerItem.canPlayFastForward will change to YES for all file-based assets and some streaming based assets (if the source playlist offers media that allows it) at the time the item becomes ready to play. The way to get notified when the player item is ready to play is by observing the AVPlayerItem.status property via Key-Value Observing (KVO). See the AV Foundation Programming Guide for the details.

The AVPlayerItem.canPlayFastForward property is not designed to indicate that playback at arbitrarily high rates is possible with no loss of smoothness.  



Document Revision History


DateNotes
2016-03-23

New document that discusses how to determine if an AVPlayerItem can be played at rates greater than 1.0.