Reputation: 774
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?
Upvotes: 0
Views: 1592
Reputation: 774
I have discovered the reason why it is not repeating. After I start the movie, I start a number of memory intensive processes, and unfortunately for me, I have so much happening on the main thread that when the movie finishes there isn't enough memory available for it to repeat. Lame.
So there is nothing wrong with the code.
Now I will be exploring using other threads for some of the processes in order to make room on the main thread for the movie to repeat.
Upvotes: 2
Reputation: 1171
This may just be the same thing you are doing but sometimes accessing properties dosen't work. You should try setRepeatMode.
Upvotes: 0