Playing multiple Videos using MPMoviePlayerController

后端 未结 1 1204
南方客
南方客 2021-01-06 23:56

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 parti

相关标签:
1条回答
  • 2021-01-07 00:05

    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.

    0 讨论(0)
提交回复
热议问题