【问题标题】:How to know when Youtube player/plugin on iPad goes fullscreen?如何知道 iPad 上的 Youtube 播放器/插件何时全屏显示?
【发布时间】:2011-04-20 00:58:47
【问题描述】:

有什么方法可以知道 iPad 上的 Youtube 播放器/插件何时全屏显示?

我有一个 UIWebview 显示在包含 Youtube 视频的模态视图控制器中。如果用户选择以全屏模式观看 Youtube 视频,它会以全屏(自然)显示,但在 UIWebview 的模态视图之后。

我想知道当视频开始以全屏模式播放时是否发送了一些通知或委托消息,以便我能够关闭我的模态视图控制器(或以某种方式将 Youtube 全屏视频放在前面)。

提前致谢。

【问题讨论】:

    标签: ipad plugins notifications youtube fullscreen


    【解决方案1】:

    我认为最好的方法是:
    1°)通过 JS 了解它(因为它在 UIWebView 内部),例如在 youtube 对象上添加 click() 事件。
    2°) 做一个 JS 动作并用 UIWebViewDelegate 捕捉它

    也许有更好的解决方案。

    祝你好运!

    【讨论】:

    • 感谢 Vinzius 的回答。我会试试你的方法。我真的对 Javascript 的细节一无所知。你能告诉我一些起点指南来实现你的建议吗?谢谢
    • 你应该看看jqtouch.com && jquery.com 这是一个很好的帮助:-) 你只需要添加一个click(); youtube 对象上的事件。然后通过尝试访问页面(使用 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType) 向 webview Delegate 发送信号
    【解决方案2】:

    对于任何感兴趣的人,我为此找到了另一种解决方法。

    我为包含 webview 的视图创建了一个自定义 UIView 继承类。响应 (BOOL)pointInside 事件,如果触摸事件发生在 YouTube 右下角的“全屏”按钮的坐标内,我传递了一个通知来触发模态视图控制器的解除。

    有点难看,但对我有用!

    【讨论】:

      【解决方案3】:

      根据@prabhu-natarajan

      在 ViewDidLoad 中添加如下代码

      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
      
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
      

      以下方法用于显示进入/退出全屏的各个过程的消息/功能

      - (void)VideoExitFullScreen:(id)sender{
       // Your respective content/function for Exit from full screen
      }
      
      - (void)VideoEnterFullScreen:(id)sender{
      // Your respective content/function for Enter to full screen
      }
      

      发件人:This link

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-10-21
        • 2014-10-27
        • 1970-01-01
        • 1970-01-01
        • 2013-01-09
        • 1970-01-01
        • 2012-12-13
        • 1970-01-01
        相关资源
        最近更新 更多