ios - Crash in -[AVPlayerItem _attachToPlayer:] An AVPlayerItem cannot be associated with more than one instance of AVPlayer -
i got crash affecting 10% of users, yet i'm unable reproduce it, , don't know when happens.
crashlytics reports half of crashing users having app not in focus, i.e. doing background audio or airplay. app plays hls video stream, , switches audio version when backgrounded.
any ideas what's wrong, or why there multiple avplayer instances singleton player class?
thanks!
exception type: nsinvalidargumentexception reason: avplayeritem cannot associated more 1 instance of avplayer fatal exception latest crash: 4/06/2013 @ 8:48:46 utc+0200 0 corefoundation __exceptionpreprocess + 162 1 libobjc.a.dylib objc_exception_throw + 30 2 avfoundation -[avplayeritem _attachtoplayer:] + 188 3 avfoundation -[avplayer _attachitem:andperformoperation:withobject:] + 336 4 avfoundation -[avplayer _insertitem:afteritem:] + 26 5 avfoundation -[avqueueplayer insertitem:afteritem:] + 136 6 mediaplayer __block_global_4 + 520 7 ... libdispatch.dylib _dispatch_call_block_and_release + 10 14
it seems solved explicitly stopping playing before setting new url, e.g.
[movieplayer stop]; movieplayer.moviesourcetype = mpmoviesourcetypestreaming; [movieplayer setcontenturl:[nsurl urlwithstring:[videos objectforkey:quality]]];