Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer not switching between progressive download and streaming

I have an app that handles streaming video. Starting with a .m3u8 playlist, it creates an array of AVAssets, and flips through them by

[player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithAsset:[assetItems objectAtIndex:index]]]

This works fine, but before that I want to air a short mp4 video using progressive downloading. I load the AVPlayer using

AVAsset *prerollAsset = [AVAsset assetWithURL:prerollURL];
[player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithAsset:prerollAsset]];

It plays, but when I continue with the streaming video as before, I get a status of AVPlayerStatusFailed, with the error in AVPlayerItem of The operation could not be completed

For it to work, I need to create an AVPlayer object for the (progressive download) preroll, and then a completely new AVPlayer object to start playing the streaming video.

Is it possible that a single AVPlayer instance isn't capable of playing progressive download video followed by streaming video? Or might there be something else I am doing wrong?

like image 603
coco Avatar asked May 31 '12 18:05

coco


1 Answers

This bug is a known issue, and purportedly fixed in the next major release of iOS.

In the interim, creating a new AVPlayer object is the only known workaround.

like image 149
Josh Tidsbury Avatar answered Oct 10 '22 18:10

Josh Tidsbury