Re: Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:]
Re: Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:]
- Subject: Re: Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:]
- From: Matt Neuburg <email@hidden>
- Date: Mon, 14 Mar 2011 10:42:01 -0700
On Sun, 13 Mar 2011 15:14:53 -0700, Steve Christensen <email@hidden> said:
>On Mar 13, 2011, at 11:05 AM, Matt Neuburg wrote:
>
>> On Tue, 08 Mar 2011 17:01:33 -0800, Steve Christensen <email@hidden> said:
>>> The setup has a MPMoviePlayerController instance that is playing a local audio file. There is also a UIWebView whose HTML contains an <audio> tag. When the play control is tapped, I see a MPMoviePlayerPlaybackDidFinishNotification notification with a reason of MPMovieFinishReasonPlaybackEnded, then gdb shows the assertion failure and exception and dumps the backtrace (below).
>>
>> What was the outcome on this? Thx - m.
>
>Well, I'm still not sure of the exact "why" for the assertion, but I figured out what I was doing that it didn't like.
>
>My MPMoviePlayerPlaybackDidFinishNotification handler is designed to queue up another audio file to play after the current one finishes. I NSLog'd the player initialization and all the notification handlers so I could watch the process more in realtime, and found that the next audio file was loaded and then very soon after got a MPMoviePlayerPlaybackDidFinishNotification. A bit after that is when the assertion failure and exception come along.
>
>After playing with it for a bit, I found that the player's loadState property is set to (MPMovieLoadStatePlayable | MPMovieLoadStatePlaythroughOK) when playback finishes normally or MPMovieLoadStateUnknown when it's stopped because another player instance has grabbed control. I've added a test that prevents the queueing if the loadState is MPMovieLoadStateUnknown and that seems to work just fine.
>
>I may have missed something in the docs that talks about this situation, but it's also probably true that I'm not using the player class in the most "standard" manner.
Thanks, Steve - mostly I just wanted to make sure that this wasn't something I was likely to encounter, and you've made clear that it isn't, since the cause of the issue was really the "automatic queuing" behavior. This explains perfectly how you could be getting a didBecomeActive notification right after playback finishes: *you* were making the MPMoviePlayerController active once again.
I guess I'm not surprised that the MPMoviePlayerController would not like your loading up an audio file while the UIWebView is already playing an audio file, since there is this rule that There Can Be Only One - for example, trying to put two MPMoviePlayerController views into your app and playing them both simultaneously won't work either. This is part of the price we pay for the simplicity of these ways of playing sound.
Glad you got it straightened out - m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden