Next/Previous buttons on iPhone MPMoviePlayerController

10,058

No notifications are generated when the user presses the next/previous buttons (you should file a bug about that), so the only way to solve this without any unapproved view-crawling is to implement your own video overlay view:

MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc]
    initWithContentURL:someUrl];
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];

NSArray* windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1) {
  UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
  [moviePlayerWindow addSubview:yourCustomOverlayView];
}

Not ideal, but the standard controls are quite easy to re-implement.

Share:
10,058
David Salzer
Author by

David Salzer

Developer, you know it..

Updated on July 20, 2022

Comments

  • David Salzer
    David Salzer almost 2 years

    When using the MPMoviePlayerController, the play button is surrounded with "Next" and "Previous" buttons.

    How do I get notifications when they are clicked? is there a way to feed MPMoviePlayerController with a list (array) of content?

  • David Salzer
    David Salzer almost 15 years
    I guess you are right. And yet, why these controls are there anyway? On the youTube application - they do move to the next/prev video.
  • Stefan Arentz
    Stefan Arentz almost 15 years
    On the iPhone they go to the start or end of the current movie. They are not next/prev buttons.
  • David Salzer
    David Salzer almost 15 years
    That is incorrect. When you implement am MPMoviePlayerController - they just exit the player in the same way "stop" would do.
  • David Salzer
    David Salzer almost 15 years
    This code is not removing the existing overlay layer. did you mean to add a clear button on them?
  • Nathan de Vries
    Nathan de Vries almost 15 years
    @yn2: I've updated my answer so that the default overlay UI is hidden.