Failed to set the initialPlaybackTime for a MPMoviePlayerController when recreating it in the second
Posted
by vicky
on Stack Overflow
See other posts from Stack Overflow
or by vicky
Published on 2010-06-04T05:28:46Z
Indexed on
2010/06/05
8:02 UTC
Read the original article
Hit count: 811
Hi, everyone. It's really wired. When at the first time a MPMoviePlayerController (e.g., theMovie) is created, its initialPlaybackTime can be set successfully. But when theMoive is released and re-create a new MPMoviePlayerController, its intialPlaybackTime can not be set correctly, actually the movie always plays from the start. The code is as follows.
-(void)initAndPlayMovie:(NSURL *)movieURL {
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
// create a notification for moviePlaybackFinish
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
theMovie.initialPlaybackTime = 15;
[theMovie setScalingMode:MPMovieScalingModeAspectFill];
[theMovie play];}
-(void) moviePlayBackDidFinish:(NSNotification*)notification { MPMoviePlayerController * theMovie = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie release]; [self initAndPlayMovie:[self getMovieURL]]; }
With the above code, when the viewcontroller did load and run initAndPlayMovie, the movie starts to play from 15 seconds, but when it plays finished or "Done" is pushed, a new theMovie is created and starts to play from 0 second. Does anybody know what happened with the initialPlaybackTime property of MPMoviePlayerController?
And whenever you reload the viewController where the above code is (presentModalViewController from a parent viewcontroller), the movie can start from any playback time. I am really confused what's the difference of the MPMoviePlayerController registration methods between the viewcontroller load and the recreating it after release.
Need your help! Thank you!
© Stack Overflow or respective owner