Presuppone iOS 3.2 o successivo. Qual è la sequenza corretta di comando per eseguire una mossa con i controlli inizialmente nascosti. Durante la riproduzione del film, l'utente ha la possibilità di taggare sullo schermo e mostrare i controlli.Come nascondere il controllo prima che venga riprodotto il film MPMoviePlayerController?
Grazie!
mio (il controllo non nascosto) Codice:
- (void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Test" ofType:@"m4v"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieDone:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieState:)
name:MPMoviePlayerNowPlayingMovieDidChangeNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieReady:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullScreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullScreen:) name:MPMoviePlayerWillExitFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
moviePlayer.controlStyle = MPMovieControlStyleDefault; // MPMovieControlStyleNone MPMovieControlStyleEmbedded MPMovieControlStyleFullscreen MPMovieControlStyleDefault
moviePlayer.scalingMode = MPMovieScalingModeAspectFill; // MPMovieScalingModeAspectFit MPMovieScalingModeAspectFill
}
}
- (void) movieReady:(NSNotification*)notification
{
MPMoviePlayerController *moviePlayer = [notification object];
if ([moviePlayer loadState] != MPMovieLoadStateUnknown) {
// Remove observer
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
// When tapping movie, status bar will appear, it shows up
// in portrait mode by default. Set orientation to landscape
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
// Add movie player as subview
[[self view] addSubview:[moviePlayer view]];
// Play the movie
[moviePlayer play];
[moviePlayer setFullscreen:YES animated:YES];
}
}
Un buon consiglio. Ho anche scoperto che impostando lo stile di controllo su 'MPMovieControlStyleFullscreen' immediatamente dopo aver chiamato play, si ottiene lo stesso risultato. Quindi forse non c'è motivo di specificare un ritardo arbitrario di 1 secondo? – curthipster
Un ritardo di un secondo ha funzionato anche per me. Ho provato mezzo secondo, ma era troppo veloce. –
Sì, anch'io ho bisogno di un ritardo ancora chiedendo perché ho bisogno di introdurre tale ritardo. –