问题
i have post this question before but cannot get a answer so i post it again.is about the MoviePlayer sample download from iphone developer site, when i press the Done button come with the movie player control mode, the movie was finish and exit to main view,at the same time the moviePlayBackDidFinish function have been called, however when i play the movie again, the player screen keep blinking,how to prevent this?
the code i didnt make any change is completly build from the sample code downloaded from apple site, have anybody met this problem before,and solve it?
回答1:
This problem is occurs only in the simulator not on the actual device. If you want to get rid of this you need to release the MoviePlayer and allocate a new one each time you play a movie. E.g.:
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
// remove observer
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:thePlayer];
[thePlayer release];
}
and
thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theMovie];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:thePlayer];
[thePlayer play];
elsewhere.
来源:https://stackoverflow.com/questions/771980/sample-code-movieplayer-problem