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
AVPlayerwith multipleAVPlayerItemsand switching between those usingreplaceCurrentItemWithPlayerItem. This works fine when switching between streaming->streaming clips or non-streaming->non-streaming, butAVPlayerdoesn’t seem to accept replacements between streaming->non-streaming or vice versa. Basically, nothing happens when I try to switch. -
Using an
AVQueuePlayerwith multipleAVPlayerItemsfails for the same reason as above. -
Using a single
AVPlayerwith a single AVPlayerItem based on anAVMutableCompositionasset. This doesn’t work because streaming content is not allowed in anAVMutableComposition(andAVURLAssetscreated from a streaming url doesn’t have anyAVAssetTracksand they are required).
So is there anything I am missing? Any other suggestion on how to accomplish this?
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: