Reputation: 6033
I'm building a video player that should handle both streaming and non-streaming content and I want it to be playable with AirPlay.
I'm currently using multiple AVPlayer
instances (one for each clip), and it works okay, but the problem is it doesn't give a very smooth experience when using AirPlay. The interface jumps back and forth between each clip when switching AVPlayer
, so I would like to migrate to using a single AVPlayer
. This seems like a trivial task, but I haven't yet found a way to do this.
This is what I've tried so far:
Using a single AVPlayer
with multiple AVPlayerItems
and switching between those using replaceCurrentItemWithPlayerItem
. This works fine when switching between streaming->streaming clips or non-streaming->non-streaming, but AVPlayer
doesn't seem to accept replacements between streaming->non-streaming or vice versa. Basically, nothing happens when I try to switch.
Using an AVQueuePlayer
with multiple AVPlayerItems
fails for the same reason as above.
Using a single AVPlayer
with a single AVPlayerItem based on an AVMutableComposition
asset. This doesn't work because streaming content is not allowed in an AVMutableComposition
(and AVURLAssets
created from a streaming url doesn't have any AVAssetTracks
and they are required).
So is there anything I am missing? Any other suggestion on how to accomplish this?
Upvotes: 4
Views: 1519
Reputation: 6033
I asked this question to Apple's Technical Support and got the answer that it's currently not possible to avoid the short jump back to menu interface, and that no version of AVPlayer supports mixing of streaming and non-streaming content.
Full response:
This is in response to your question about how to avoid the short jump back to the main interface when switching AVPlayers or AVPlayerItems for different media items while playing over AirPlay.
The issue here is the same with AVPlayer and AVQueuePlayer: no instance of AVPlayer (regardless of which particular class) can currently play both streaming and non-streaming content; that is, you can't mix HTTP Live Streaming media (e.g. .m3u8) with non-streaming media (a file-based resource such as an .mp4 file).
And with regard to AVMutableComposition, it does not allow streaming content.
Currently, there is no support for "seamless" video playback across multiple items. I encourage you to file an enhancement request for this feature using the Apple Bug Reporter (http://developer.apple.com/bugreporter/).
AVComposition is probably the best option at present for "seamless" playback. However, it has the limitation just described where streaming content is not allowed.
Upvotes: 1