MPMoviePlayerController delay when there should be virtually none
each time my app changes the displayed animation, which is a looping movie, he takes a pause till he finally start the movie. The MoviePlayerConntroller is created this way
self.moviePlayer = [MPMoviePlayerController alloc];
[moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"NewChar" ofType:@"m4v"]] ];
// remove playerview from our view (no prob is he isnt attached to any)
[moviePlayer.view removeFromSuperview];
// tell our playerview the size he has to use
moviePlayer.view.frame = CGRectMake(0, 0, 320, 430);
// and add hin to the superview behind everything else
[self.view insertSubview:moviePlayer.view atIndex:0];
// no moviecontrolls
moviePlayer.controlStyle = MPMovieControlStyleNone;
// looping forever
moviePlayer.repeatMode= MPMovieRepeatModeOne;
// let him use his own Audio Session for old devices
moviePlayer.useApplicationAudioSession= NO;
// fix the silly black background on iOS 4.3
moviePlayer.开发者_Go百科view.backgroundColor = [UIColor clearColor];
the actual movie is played this way
[moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Whatever" ofType:@"m4v"]]];
[moviePlayer play];
Just as I said, each time the movie is changed, he takes a while to display it. On newer devices its ok, since they are faster, but on G2 it is somewhat disturbing. Tried prepare playback, but that makes no difference.
Any idea what I missed?
Thanks for reading! :)
It takes time to load up the movie from disk, and obviously will be slower on older devices. How big is the video?
精彩评论