AVPlayer replaceCurrentItemWithPlayerItem isn't working over AirPlay

Originator:ben
Number:rdar://14275234 Date Originated:26/06/2013
Status:Closed Resolved:
Product:iOS SDK Product Version:>= iOS5
Classification:Serious Bug Reproducible:Always
 
Summary:
While using AVPlayer over AirPlay the method replaceCurrentItemWithPlayerItem: doesn't do a thing.

Steps to Reproduce:
Set up an AVPlayer, create AVPlayerItem, play over AirPlay and invoke replaceCurrentItemWithPlayerItem: after some time.

Expected Results:
AVPlayer/AirPlay should playback the new item.

Actual Results:
Nothing.

Regression:
Our app runs on >= iOS 5.1, I was able to reproduce it with various versions up to 6.1.4.

Notes:


[UPDATE]
Works on iOS7 beta 2 and AppleTV beta

Comments

I ran into this issue as well and found a workaround on iOS 5, 6, and 7 (legacy mode). This happens because the AVPlayerItem status never changes to ReadyToPlay after calling replaceCurrentItemWithPlayerItem: while on AirPlay.

The following workaround results in ReadyToPlay status being reached:

1) Before calling replaceCurrentItemWithPlayerItem: set AVPlayer property allowsExternalPlayback (iOS 6+) or allowsAirPlayVideo (iOS 5) to NO. I do this in my setContentURL: method which eventually ends up calling replaceCurrentItemWithPlayerItem:.

if ([self.player respondsToSelector:@selector(setAllowsExternalPlayback:)]) { self.player.allowsExternalPlayback = NO; // iOS 6 } else { self.player.allowsAirPlayVideo = NO; // iOS 5 }

2) After calling replaceCurrentItemWithPlayerItem: set them back to YES. I do this in the KVO callback for AVPlayer.currentItem.

if ([self.player respondsToSelector:@selector(setAllowsExternalPlayback:)]) { self.player.allowsExternalPlayback = YES; // iOS 6 } else { self.player.allowsAirPlayVideo = YES; // iOS 5 }


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!