2013-08-05 15 views
6

Pracuję z MPMoviePlayerViewController,Jak wyłączyć pełnym ekranie MPMoviePlayerViewController w iOS

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

Funkcja ta działa poprawnie. Ale muszę wyłączyć pełny ekran dla MPMoviePlayerViewController. Tak więc napisałem:

avPlayer.moviePlayer.fullscreen=NO; 

Ale to nie działa.

Czy możesz dać mi sugestię.

Odpowiedz

0

Ten kod służy do wyłączania pełnego ekranu w MPMoviePlayerViewController.

moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleNone; 

lub zaznacz to, aby wprowadzić kontroler widoku.

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

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

Mam nadzieję, że ten kod będzie dla Ciebie przydatny.

+1

To nie będzie prawidłowo funkcjonować. Spróbuj tego, użyj tego kodu, a następnie użyj gestu uszczypnięcia, aby skalować w górę lub w dół -> bam! – Till

-3

Spróbuj tego ...

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

Proszę sprawdzić this answer

+0

@Ravan: Sprawdź link ... to wiele alternatyw ... –

Powiązane problemy