iPad MPMoviePlayerController - Disable Fullscreen

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

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

16条回答
  •  旧巷少年郎
    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:
    }
    

提交回复
热议问题