关闭 MPMoviePlayerViewController 的全屏模式时出现问题

发布于 2024-12-05 14:59:06 字数 225 浏览 0 评论 0原文

在我的应用程序中,我使用 MPMoviePlayerViewController 来播放在线视频。视频在横向模式下应以全屏模式播放,而在旋转到纵向模式时应关闭全屏模式。 我能够以全屏模式播放视频。但当设备方向更改为纵向模式时无法关闭它。

我正在使用 [mpController.movi​​ePlayer setFullscreen:FALSE 动画:YES];

请有人帮忙。

提前致谢。

In my application i am using MPMoviePlayerViewController to play online video. The video should play in fullscreen mode when in landscape and the fullscreen mode should be dismissed when it rotates to portrait mode.
I am able to play the video in fullscreen mode. But not able to dismiss it when the device orientation changes to portrait mode.

I am using [mpController.moviePlayer setFullscreen:FALSE animated:YES];

Someone please help.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

攒眉千度 2024-12-12 14:59:06

我假设您正在尝试检测呈现 MPMoviePlayerViewController 的视图控制器中的方向变化?呈现电影播放器​​视图控制器后不会触发此代码,因为它(而不是其父级)将接收旋转事件。

但是,您可以订阅设备旋转通知,并在检测到纵向旋转时关闭电影播放器​​视图控制器:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil];

// Present MPMoviePlayerViewController here

在同一视图控制器的其他位置:

- (void)deviceOrientationDidChange:(NSNotification *)notification
{
    UIDevice *currentDevice = [UIDevice currentDevice];
    [currentDevice endGeneratingDeviceOrientationNotifications];

    if (...)        // Check currentDevice.orientation to see if it's what you want
    {
        // Do whatever you want now that you have the orientation you want
    }

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}

I assume you're trying to detect the orientation change in the view controller that present MPMoviePlayerViewController? This code won't be fired after the movie player view controller is presented because it—not its parent—will receive the rotation events.

You can, however, subscribe to the device rotation notifications and dismiss the movie player view controller whenever you detect a rotation to portrait:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil];

// Present MPMoviePlayerViewController here

Elsewhere in the same view controller:

- (void)deviceOrientationDidChange:(NSNotification *)notification
{
    UIDevice *currentDevice = [UIDevice currentDevice];
    [currentDevice endGeneratingDeviceOrientationNotifications];

    if (...)        // Check currentDevice.orientation to see if it's what you want
    {
        // Do whatever you want now that you have the orientation you want
    }

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}
硬不硬你别怂 2024-12-12 14:59:06

UIDeviceOrientationDidChangeNotificationUIApplicationWillChangeStatusBarOrientationNotification 设置观察者,检查新的所需方向并为 MPMoviePlayerViewController 设置新模式。

Set observer for UIDeviceOrientationDidChangeNotification or UIApplicationWillChangeStatusBarOrientationNotification, check new required orientation and set new mode for MPMoviePlayerViewController.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文