Estoy creando un objeto MPMoviePlayerController y estoy transmitiendo un video en modo de pantalla completa.MPMoviePlayerController no elimina la vista al hacer clic en
Estoy usando un UIViewController para mostrar la vista de la película.
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//http://www.youtube.com/watch?feature=player_detailpage&v=ebeQaznNcmE
NSURL *url = [NSURL URLWithString:@"http://a1408.g.akamai.net/5/1408/1388/2005110405/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_mpeg4.mp4"];
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
mPlayer.view.frame = gMainView.frame;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mPlayer];
mPlayer.shouldAutoplay = YES;
mPlayer.controlStyle = MPMovieControlStyleFullscreen;
[gMainView addSubview:mPlayer.view];
[mPlayer prepareToPlay];
[mPlayer setFullscreen:YES animated:YES];
[mPlayer play];
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackEnded) {
//movie finished playing
}
else if (reason == MPMovieFinishReasonUserExited) {
//user hit the done button
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}
else if (reason == MPMovieFinishReasonPlaybackError) {
//error
}
}
al hacer clic hecho, el video visual se elimina de la pantalla, pero los controles no se eliminan de la pantalla y la vista no se elimina de la pantalla.
El control llega a "// usuario pulse el botón hecho". Ejecuta el código para eliminar la vista de la supervista, comprobé agregando registros, pero los controles no se eliminan de la pantalla y la vista no se elimina de la pantalla. ¿Qué estoy haciendo mal?
EDIT:
Si uso MPMoviePlayerViewController entonces ni siquiera esperó a que pulse Hecho. Una vez que el video se completa, elimina automáticamente la vista. Pero no quiero eso.
EDIT:
Si quito "[mPlayer setFullscreen: SÍ animada: SÍ]", entonces al hacer clic en Hecho, la vista se elimina completamente. Pero el video no se muestra en pantalla completa y la barra de estado se vuelve gris, que es nuevamente lo que no quiero.
Usted tomar muchas medidas para describir lo que no quiere, pero, al menos para mí, esto todavía no es realmente afirmar lo que realmente quiere lograr. – Till
Los controles no se eliminan de la pantalla y la vista del reproductor no se elimina de la pantalla. – Anand
Pruebe esta solución: http://stackoverflow.com/questions/6142571/mpmovieplayer-done-button-issue/6142685#6142685 – Till