views:

141

answers:

2

Right now i am use using mpmovieplayercontroller, but i need to close mpmovieplayercontroller for play another video. Is there a way to play several videos without closing the mpmovieplayercontroller?

thx

+3  A: 

You can subscribe to your MPMoviePlayerController's MPMoviePlayerPlaybackDidFinishNotification notification.

For example, you have:

// this is a PoC code, you can do it a lot cleaner
// in your .h
@property (nonatomic, retain) MPMoviePlayerController *moviePlayer;
@property (nonatomic, retain) NSMutableArray *movieUrls; 
int indexPlayed;

// in your .m
- (void)setupPlayer { // or in your constructor, viewDidLoad, etc
    moviePlayer = [[MPMoviePlayer alloc] init];
    movieUrls = [NSMutableArray arrayWithObjects:nil, nil, nil]; // add your movie NSURLs here
    indexPlayed = 0;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlay:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
    [self playerPlay:nil];
}
- (void)playerPlay:(NSNotification *)n {
    if (indexPlayed < [movieUrls count]) {
        moviePlayer.contentURL = [movieUrls objectAtIndex:indexPlayed++];
        [moviePlayer play];
    }
}
Prody
A: 

good tutorial on how to stream video:

http://buildmobilesoftware.com/2010/08/09/how-to-stream-videos-on-the-iphone-or-ipad/

Sheehan Alam