iPad MPMoviePlayerController - Disable Fullscreen

后端 未结 16 2076
一向
一向 2020-12-06 01:38

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

相关标签:
16条回答
  • 2020-12-06 02:06

    There's a cheat:

    MPMoviePlayerController *mpc = (...some instance...)
    UIView *fsbutton = [[mpc view] viewWithTag:512];
    [fsbutton setHidden:YES];
    

    The main catch is, you have to do it in viewDidAppear: or similar, because the MoviePlayer view sets itself up somewhere inside didMoveToWindow or didMoveToSuperview, which happen after viewWillAppear:. So you get a brief flash of the fullscreen button. Other obvious catches include: brittle vs. Apple changing that 512 tag value (although it works in 3.2 - 4.2); and of course Apple would rather you not do this.

    The endorsed solution is to set the control style to MPMovieControlStyleNone and roll your own transport controls, which is more work.

    0 讨论(0)
  • 2020-12-06 02:06

    Simple block to remove pinch zoom here

    Hope it help

    it work with me on iOS6

     for (UIView *view in  moviePlayer.view.subviews) {
    
        for(UIPinchGestureRecognizer *pinch in view.gestureRecognizers){
        if([pinch isKindOfClass:[UIPinchGestureRecognizer class]])
            [view removeGestureRecognizer:pinch];
        }
    }
    
    0 讨论(0)
  • 2020-12-06 02:06

    If the only thing you want to do is disable pinch to go full screen (i.e. keep interaction enabled and whatever control style you want), you can use this:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    
        NSSet *set = [event allTouches];
        NSArray *arr = [set allObjects];
        for (int i = 0; i < arr.count; i++) {
            UITouch *touch = (UITouch *) [arr objectAtIndex:i];
    
            NSArray *recognisers = touch.gestureRecognizers;
            for (UIGestureRecognizer *recogniser in recognisers) {
                if (recogniser.enabled && [recogniser isMemberOfClass:[UIPinchGestureRecognizer class]]) {
                    recogniser.enabled = NO;
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-06 02:08

    Fullscreen button along with pause button can be removed.

    [self.videoPlayer setControlStyle:MPMovieControlStyleNone];
    
    0 讨论(0)
  • 2020-12-06 02:08

    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.

    0 讨论(0)
  • 2020-12-06 02:11

    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];
    }
    
    0 讨论(0)
提交回复
热议问题