6

我正在MPMoviePlayerViewController

MPMoviePlayerViewController *avPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
// [movieView prepareToPlay];

[avPlayer.view setFrame: CGRectMake(0, 200, 320, 100)];  // player's frame must match parent's
[avPlayer shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
[avPlayer shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft];
avPlayer.moviePlayer.scalingMode=MPMovieScalingModeAspectFit;
avPlayer.moviePlayer.useApplicationAudioSession=NO;
avPlayer.moviePlayer.controlStyle=MPMovieControlStyleEmbedded;
//avPlayer.moviePlayer.repeatMode=MPMovieRepeatModeOne;
avPlayer.moviePlayer.scalingMode=MPMovieScalingModeFill;
[self.view addSubview: avPlayer.view];

此功能运行良好。但我需要禁用全屏MPMoviePlayerViewController。所以,我写的

avPlayer.moviePlayer.fullscreen=NO;

但这不起作用。

请你给我建议。

4

2 回答 2

0

使用此代码禁用全屏MPMoviePlayerViewController

moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleNone;

或检查此项以输入您的视图控制器。

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

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

我希望这段代码对你有用。

于 2013-08-05T07:02:15.407 回答
-3

尝试这个...

- (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];
}

请检查这个答案

于 2013-08-05T07:03:31.840 回答