MPMoviePlayerController: How can I make my video loop?

Jay L picture Jay L · Jan 2, 2011 · Viewed 11.6k times · Source

Thank you in advance for any help, I am a newbie and would appreciate any help here.. I have this code to play a movie and it works great. Can somebody PLEASE tell me how to make this movie loop and replay from the beginning non stop ( any code would help). Also I would like to know how to play 2 movies, one after the other, preferably with a fade or smooth transition. Thank you for any help

#import "MyAppViewController.h"

@implementation MyAppViewController

-(IBAction)button:(id)sender{
 NSString *path = [[NSBundle mainBundle]
       pathForResource:@"mymovie" ofType:@"mp4"];

 player = [[MPMoviePlayerViewController alloc]
     initWithContentURL:[NSURL fileURLWithPath:path]];

 [self presentMoviePlayerViewControllerAnimated:player];

}

Answer

Jacob Relkin picture Jacob Relkin · Jan 2, 2011

Set the repeatMode property of your MPMoviePlayerController to MPMovieRepeatModeOne

player = [[MPMoviePlayerViewController alloc]
          initWithContentURL:[NSURL fileURLWithPath:path]];
player.moviePlayer.repeatMode = MPMovieRepeatModeOne;