MPMoviePlayerViewController / MPMoviePlayerController will not play the same movie twice?
Steps to replicate: 1. Call playMovieAtURL. Use this url: (http://nov8rixstorage.blob.core.windows.net/searchpad/tutorial_portrait.mov) 2. Let the movie start then press Done. 3. Call playMovieAtURL again using the same URL.
Result: MPMoviePlayerViewController animates in; flashes a few times; and closes with error in notification object. ("Server is not co开发者_StackOverflow中文版rrectly configured.")
This is very strange. Making things stranger; the movie player will not play anything again until the app is deleted from the device (simulator or iphone). Upon re-deployment it will play the movie perfectly once again; but alas on the second play it will repeat the above behavior.
What am I doing wrong? Can anyone reproduce this?
- (void) playMovieAtURL: (NSURL*) theURL {
[theURL retain];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:theURL];
if (mp)
{
[self presentMoviePlayerViewControllerAnimated:mp];
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(playbackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp.moviePlayer];
[mp release];
}
[theURL release];
}
-(void) playbackDidFinish:(NSNotification*)aNotification
{
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
[self dismissMoviePlayerViewControllerAnimated];
}
Edit: Can anyone replicate this? Anyone?
try moviePlayer.repeatMode = MPMovieRepeatModeOne;
I think instead of:
MPMoviePlayerController *player = [aNotification object];
You should write:
MPMoviePlayerViewController *player = [aNotification object];
精彩评论