Reputation: 11747
I have an iOS app with a MPMoviePlayerController, I need to play a video from an URL. Everything seems to work fine, but when the playback ends the MPMoviePlayerController shows a weird image and it takes AGES to replay the video...
This is what I have so far:
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
And the moviePlayerLoadStateChanged and moviePlayBackDidFinish look like this:
- (void) moviePlayerLoadStateChanged:(NSNotification*)notification
{
if ([mp loadState] != MPMovieLoadStateUnknown)
{
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[mp setControlStyle:MPMovieControlStyleEmbedded];
[mp setFullscreen:NO];
[mp.view setFrame:CGRectMake(10, 54, 300, 200)];
[mp setShouldAutoplay:NO];
[mp prepareToPlay];
[[self view] addSubview:[self.mp view]];
}
}
I don't know what that Image is, but I would like to replace it... also I think it takes so much because it's loading the video from a URL, I don't know how to add a loading, or a spinner... Any idea?
Upvotes: 1
Views: 553
Reputation: 187
You could set the repeatMode
property of your MPMoviePlayerController
to MPMovieRepeatModeOne
by using:
mp = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:path]];///Put your path to your resource
mp.moviePlayer.repeatMode = MPMovieRepeatModeOne;
I hope this helps if i understood your question correctly. If not i recommend checking out the documentation HERE
Happy coding:)
Upvotes: 1