versiones guia espaƱol descargar actualizar ios mpmovieplayercontroller landscape

ios - guia - qgis manual



MPMoviePlayerViewController | Permitir modo paisaje (4)

@peko dice la manera correcta. cuando el usuario sale del video de pantalla completa, este método se vuelve a MPMoviePlayerViewController con la clase MPMoviePlayerViewController . debe verificar si se descarta o no, si no lo hace, cuando el usuario salga del video, la ventana principal permanecerá en modo horizontal y también olvidó la clase MPInlineVideoFullscreenViewController . cuando usas un reproductor incrustado (no en pantalla completa) se llama con ese nombre de clase.

Lo hice así. esto funciona para mi.

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)windowx { if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]] || [[self.window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"MPInlineVideoFullscreenViewController")]) { if ([self.window.rootViewController presentedViewController].isBeingDismissed) { return UIInterfaceOrientationMaskPortrait; } else { return UIInterfaceOrientationMaskAllButUpsideDown; } } else { return UIInterfaceOrientationMaskPortrait; } }

Estoy tratando de transmitir un video en mi aplicación. El método que he encontrado es:

NSURL *theMovieURL = [NSURL URLWithString:self.data.trailer]; if (theMovieURL) { self.movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:theMovieURL]; [self presentMoviePlayerViewControllerAnimated:self.movieController]; [self.movieController.moviePlayer play]; }

No estoy seguro de si es el más convencional, pero funciona.

El problema es que no puedo descubrir cómo permitir el modo horizontal, solo para el video. ¿Debo usar algo como shouldAutorotate o shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation , y cómo?

Para su información, toda la aplicación permite solo el modo de retrato.

Gracias por tu ayuda.


Es posible que el reproductor de películas no sea el primer controlador de vista presentado, por lo que debería hacer algo como esto

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { UIViewController* playerController = self.window.rootViewController.presentedViewController; while (playerController && ![playerController isKindOfClass:[MPMoviePlayerViewController class]]) { playerController = playerController.presentedViewController; } if (playerController && !playerController.isBeingDismissed) { return UIInterfaceOrientationMaskAllButUpsideDown; } else { return UIInterfaceOrientationMaskPortrait; } }

Aunque MPMoviePlayerViewController ha quedado en desuso, por lo tanto, debería usar AVPlayerViewController y verificar su clase también en este bucle.


La mejor manera hasta ahora es implementar esta función AppDelegate y verificar si el rootViewController tiene un hijo de tipo AVPlayerViewController o MPMoviePlayerViewController luego regresa [.portrait, .landscapeLeft, .landscapeRight] y otra .portrait .

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if let _ = UIApplication.shared.keyWindow?.rootViewController?.childViewControllers.first as? AVPlayerViewController { return [.portrait, .landscapeLeft, .landscapeRight] } return .portrait }

Debería verificar en la keyWindow de la aplicación UIApplication porque Apple presenta este viewController en otra UIWindow por lo que si intenta hacer esa verificación en la ventana que está declarada en la AppDelegate esto no funcionará, así que tenga cuidado.


shouldAutoRotate está en desuso a partir de iOS 6 y debe evitarse a menos que vaya por <6.

En su lugar, desearía anular los métodos supportedInterfaceOrientations Interorientación de Orientación y preferredInterfaceOrientationForPresentation Interfaz de preferredInterfaceOrientationForPresentation Interfaz.

En este caso, si no desea crear una subclase del reproductor de medios, podría anular un método en el delegado de la aplicación de la siguiente manera:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAllButUpsideDown; } else { return UIInterfaceOrientationMaskPortrait; } }