0

This one is baffling me. If anyone has any answers, they are appreciated.

I have the following method which plays a video during a loading process in my app:

-(void)playLoadingMovie
{
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
movieController.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[movieController.moviePlayer setControlStyle:MPMovieControlStyleNone];
[movieController.view setFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
[self.view addSubview:movieController.view];
NSLog(@"repeatMode: %d",movieController.moviePlayer.repeatMode);
}

Everything is properly declared, synthesized, released, etc... in the appropriate places and situations elsewhere in the code. This particular method works just fine, except for the fact that it does not repeat as it should.

You can see that the repeatMode is set to MPMovieRepeatModeOne, and when I run the code, the log statement prints out "repeatMode: 1" just as it should.

I know that I can do something hackish and set an observer for when the movie finishes and have it call a method to play the movie again, but I would much rather have this code work properly.

Any ideas?

4

2 回答 2

2

我发现了它不重复的原因。开始播放电影后,我启动了许多内存密集型进程,不幸的是,我在主线程上发生了太多事情,以至于当电影结束时,没有足够的内存可供重复。瘸。

所以代码没有问题。

现在我将探索在某些进程中使用其他线程,以便在主线程上腾出空间让电影重复。

于 2011-05-27T19:18:18.583 回答
0

这可能与您正在做的事情相同,但有时访问属性不起作用。您应该尝试 setRepeatMode。

于 2011-05-26T22:04:06.423 回答