MPMoviePlayerController 5秒后停止播放video

我试图在iOS上播放video,但只播放了5个video。 这是我的代码:

NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath = [bundle pathForResource:@"videoviewdemo" ofType:@"mp4"]; NSURL *movieURL = [[NSURL alloc]initFileURLWithPath:moviePath]; MPMoviePlayerController *theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; theMoviPlayer.controlStyle = MPMovieControlStyleFullscreen; theMoviPlayer.controlStyle = MPMovieControlStyleDefault; [theMoviPlayer setMovieSourceType:MPMovieSourceTypeFile]; theMoviPlayer.shouldAutoplay = YES; theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2)); [theMoviPlayer.view setFrame:self.view.frame]; [theMoviPlayer prepareToPlay]; [self.view addSubview:theMoviPlayer.view]; 

声明一个ivar @property (nonatomic,strong) MPMoviePlayerController *myMovieController;

分配给它的MoiPlayer如下,

 self.myMovieController = theMoviPlayer; [self.view addSubview: self.myMovieController.view]; 

然后播放电影。

这个问题似乎是theMoviPlayer不被保留。