Fahad Jamal
Fahad Jamal

Reputation: 341

Playing multiple Videos using MPMoviePlayerController

In my app i have multiple Videos and i want that when the user press the next or previous button in the MPMoviePlayerController, the MPMoviePlayerController should the particular song.But the problem is that the MPMoviePlayerController has only the notification for the SeekingForward or for Backward. How to implement the previous and next functionality using the FastForward and the BackWard Button inside the MPMoviePlayerController.

Upvotes: 2

Views: 5039

Answers (1)

Shamsudheen TK
Shamsudheen TK

Reputation: 31311

Apple introduced new class Called AVQueuePlayer using this you can play many videos at a time this class is worth using then MPMoviePlayerController which not support playing multiple movies.

AVQueuePlayer is avalible from IOS 4.1 and above it is subclass AVPlayer. If u familiar with AVPlayer

You can change current running movie with call

[self.queuePlayer advanceToNextItem];

You can look at the sample code here

You can download the sample application from here

Another Idea (worst case).

Register for the notification with

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

And add this function to your object:

-(void)moviePlayerPlaybackStateChanged:(NSNotification *)notification {
    MPMoviePlayerController *moviePlayer = notification.object;
    MPMoviePlaybackState playbackState = moviePlayer.playbackState;
    // ...
}

I suspect you'll find that you're getting MPMoviePlaybackStateSeekingForward and ...SeekingBackward updates for those buttons.

See the details here

And set the corresponding URL's for the MPMoviePlayerController or initialize again the MPMoviePlayerController with the corresponding URL's.

Upvotes: 2

Related Questions