Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer "Cannot Complete Action"

Im getting this error after playing several videos:

Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo=0x1d83a7f0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}

My play function looks like this:

- (void)playItem:(AVPlayerItem*)item
  playerView:(PlayerView*)playerView
     doReset:(BOOL)reset
{
// if it's different item or we want to reset then replace item and rewind player to zero
if([player currentItem] != item || reset)
{
    [player pause];
    [player replaceCurrentItemWithPlayerItem:item];
    [player seekToTime:kCMTimeZero];
}

// set the view's player
[playerView setPlayer:player];

[player play];

The player only stops working after a couple of hundred attempts. I have 5 PlayerView's which are 5 Videos that when touched will play. To get to a point where i get this error (only by looking at AVPlayer instance error property) i have to touch these buttons severl times (like mentioned before it goes from couple of hundred to thousand times). I have tried all kinds of stuff to fix this but no success. I know that if i add this line [playerView setVideoFillMode:AVLayerVideoGravityResizeAspectFill] will make this error come early ( bebore 200 times). What i haven't tried is to use a single PlayerView that will be reused for each button, but i will have to play more than one video at the same time in the future and i think it will bring out this problem after a while. Googling this error or wither searching StackOverflow didn't bring me no solutions so far.

Does anyone experience this kin of problems? It happens either in iOS5 or iOS6 (not targeting bellow 5) with ARC.

Thanks in advance

like image 859
alamatula Avatar asked Feb 11 '13 19:02

alamatula


1 Answers

I'm not set-up to try your code, but have you tried wrapping replaceCurrentItemWithPlayerItem: in @autoreleasepool to force ARC to do some cleanup?

Alternately, have you checked allocations via Instruments?

From your description, it sounds a lot like a leak. You may have found a bug in AVPlayer (I doubt it's gotten the kind of exercise you're giving it!) and, if so, you should definitely file a bug with Apple, but there may be some things you can do to work around.

Is there a reason you want to keep re-using the same player? Have you tried ditching the old player and creating a new one, rather than replaceCurrentItemWithPlayerItem: ?

Let us know what Instruments-Allocations shows. I bet that's key in getting to the bottom of this.

like image 131
Olie Avatar answered Oct 25 '22 07:10

Olie