iPad MPMoviePlayerController - Disable Fullscreen

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

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

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

    You could hide the playback controls and add your own custom ones, this will prevent the default buttons being rendered at all

    I.e with

    [player setMovieControlMode:MPMovieControlModeNone];
    
    0 讨论(0)
  • 2020-12-06 02:01

    Depending on your needs, you can also simply disable all user interactions on the player view.

    player.view.userInteractionEnabled = NO;
    
    0 讨论(0)
  • 2020-12-06 02:01

    in order to disable switch to full screen mode, either form button or pinch gesture, you can use this:

    moviePlayer.controlStyle = MPMovieControlStyleNone;
    moviePlayer.view.userInteractionEnabled =NO; 
    
    0 讨论(0)
  • 2020-12-06 02:01

    I know, it's a little outdated, but anyway. I did some research in that direction, and looks like a found an answer. I do not know, why it's working, but it is.

    -(void) playMovieAtURL: (NSURL*) theURL {
    
        MPMoviePlayerController* theMovie =
        [[MPMoviePlayerController alloc] initWithContentURL: theURL];
        //That line is for ARC. Without it, it may not work.
        self.moviePlayer = theMovie;
        theMovie.scalingMode = MPMovieScalingModeAspectFill;
        theMovie.controlStyle = MPMovieControlStyleFullscreen;
        theMovie.repeatMode  = MPMovieRepeatModeOne;
        //Here you'd better use your custom ViewController subclass, if you want autorotating and all that stuff.
        UIViewController * vc = [UIViewController new];
        [vc.view addSubview:theMovie.view];
        theMovie.fullscreen  = YES;
        theMovie.view.frame = vc.view.bounds;
        vc.view = theMovie.view;
        [self presentModalViewController:vc animated:YES];
        theMovie.fullscreen  = YES;
    
        [theMovie prepareToPlay];
        [theMovie play];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    }
    

    // When the movie is done, release the controller.

    -(void) myMovieFinishedCallback: (NSNotification*) aNotification
    {
        [self dismissModalViewControllerAnimated:YES];
        MPMoviePlayerController* theMovie = [aNotification object];
        [[NSNotificationCenter defaultCenter]
     removeObserver: self
     name: MPMoviePlayerPlaybackDidFinishNotification
     object: theMovie];
        [self.moviePlayer.view removeFromSuperview];
        self.moviePlayer = nil;
        // Release the movie instance created in playMovieAtURL:
    }
    
    0 讨论(0)
  • 2020-12-06 02:02

    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)

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

    You can set controlStyle to Fullscreen. these controls are somewhat different, but it doesn't feature a Fullscreen button!

    [_moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];
    
    0 讨论(0)
提交回复
热议问题