Search code examples
iphonexcodeipadmpmovieplayercontrolleripod

iPhone: Play videos automatically in a sequence, one after another


i built a very basic video player app in Xcode 4.3.2 i have 3 small videos and on my main menu i have 3 buttons. One button for each video my code looks like this.....

- (IBAction)playMoviePressed1:(id)sender 
{

NSString *path = [[NSBundle mainBundle]
                  pathForResource:@"HomeVideoOne" ofType:@"m4v"];

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

[self presentMoviePlayerViewControllerAnimated:player];
}

And it repeats for videos 2 and 3. I would like to have a 4th button that played all 3 videos in order without stopping and having to select the next one. It's almost like having to play chapters in a movie one at a time.

Here's the kicker, I don't want to make any extra video files to add to the project size. So in other words the only way i am able to accomplish my goal so far is to edit all 3 videos into one .m4v file and import that to the project. But that is no good because it doubles my project size. I'd like to call on the existing files to play in one right after another with no break. I hope I didn't sound to repetitious. Thank You -ANthony


Solution

  • In this case you will need to use some more advanced API like AVQueuePlayer instead of a basic MPMoviePlayerController Try look through the document here first http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html