iPad MPMoviePlayerController - Disable Fullscreen

2019-01-14 16:54发布

Is there a way to disable the fullscreen button of the MPMoviePlayerController ?

16条回答
男人必须洒脱
2楼-- · 2019-01-14 17:27

Put a UIView or UIButton with transparent background on top of the view that shows the video, so that the user won't be able to tap on the view that contains the video.

查看更多
The star\"
3楼-- · 2019-01-14 17:28

Wired does this. For the videos that start in fullscreen, they have the standard MPMoviePlayerController controls, but are missing the fullscreen buttons. And they're using the standard built-in ones, since they suddenly got an AirPlay button with 4.2.

查看更多
在下西门庆
4楼-- · 2019-01-14 17:29

This is the Swift version of the first solution of Javier Calatrava Llavería:

func hideFullScreenButton() {
    self.hideFullScreenSubview((self.moviePlayerController?.view.subviews)!)
}

func hideFullScreenSubview(subviews: [UIView]) {
    for view: UIView in subviews {
        if view.subviews.count > 0 {
            self.hideFullScreenSubview(view.subviews)
        }
        if view.frame.origin.x == 631 {
            view.hidden = true
        }
    }
}

And when the user taps on Play:

self.performSelector(#selector(VideoViewController.hideFullScreenButton), withObject: self, afterDelay: 0.5)

(VideoViewController is the view controller in which I have the MPMoviePlayerController)

查看更多
Lonely孤独者°
5楼-- · 2019-01-14 17:30

Just did it:

- (void)viewDidLoad {
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieEventFullscreenHandler:) 
                                                 name:MPMoviePlayerWillEnterFullscreenNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieEventFullscreenHandler:) 
                                                 name:MPMoviePlayerDidEnterFullscreenNotification 
                                               object:nil];

    self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
}

- (void)movieEventFullscreenHandler:(NSNotification*)notification {
    [self.moviePlayer setFullscreen:NO animated:NO];
    [self.moviePlayer setControlStyle:MPMovieControlStyleEmbedded];
}
查看更多
Ridiculous、
6楼-- · 2019-01-14 17:31

This worked on iOS 7, iPhone 5s.

Add Notification:

MPMoviePlayerDidEnterFullscreenNotification : @"moviePlayFullscreenNote:"

- (void)moviePlayFullscreenNote:(NSNotification*)notification
{
    if (notification.object == self.videoPlayer)
    {
        [self.videoPlayer setFullscreen:NO animated:YES];
        self.videoPlayer.controlStyle = MPMovieControlStyleEmbedded;
    }
}

Notice that I only listen for "DID" and not the "WILL" notification as well as running it animated. I think this works as it gives the system time to react. When I used the "WILL" and "DID" as noted in answers above it led to a black screen with no controls. There is a slight glitch that is visible when the transition occurs, but I need the play/scrub buttons from embedded.

查看更多
放我归山
7楼-- · 2019-01-14 17:33

No, there is no way. Hopefully with the next update.

查看更多
登录 后发表回答