【问题标题】:Problem in dismissing fullscreen mode of MPMoviePlayerViewController关闭 MPMoviePlayerViewController 的全屏模式时出现问题
【发布时间】:2011-09-21 14:13:27
【问题描述】:

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

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

请有人帮忙。

提前致谢。

【问题讨论】:

    标签: iphone ios ipad mpmovieplayercontroller


    【解决方案1】:

    我假设您正在尝试检测呈现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];
    }
    

    【讨论】:

    • 我没有展示 MPMoviePlayerViewController。我正在使用 addSubView。
    • 好吧,好吧,那不应该真的改变任何东西。当设备旋转以确定如何处理您的电影播放器​​视图时,您仍然需要挂钩逻辑。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 2013-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多