【问题标题】:Not smooth rotation of UIWebView embedded Youtube videoUIWebView 嵌入的 Youtube 视频旋转不流畅
【发布时间】:2014-07-22 21:30:15
【问题描述】:

我正在使用 Youtube iOS 帮助程序库在我的应用程序中内嵌播放 YT 视频。我的应用程序通常运行流畅,视频加载和播放正常。我有一个问题,当我旋转手机(模拟器)时,视频会离开框架。因此,如果我以纵向加载视频,则视频将以纵向居中,但当我旋转为横向时,视频将位于底角。

为了解决这个问题,我现在用一些 javascript 来调整播放器的大小。

- (void)setSizeOfIFrameToWidth:(int)width Height:(int)height {
[self.webView stringByEvaluatingJavaScriptFromString:
    [NSString stringWithFormat:@"player.setSize(%d, %d)", width, height]];
}

(在我编辑的 YTPlayer 类中)。

这工作正常并在 youtubeView 的所有者中被调用:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    [self.youtubeView setSizeOfIFrameToWidth:self.youtubeView.frame.size.width Height:self.youtubeView.frame.size.height];
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [self.youtubeView setNeedsDisplay];
}

(我不确定最后setNeedsDisplay 行是否有任何作用)

但是现在,当它旋转时,首先视图在侧面被切断,然后旋转笨拙。它看起来非常波涛汹涌。这是我能得到的最好的截图:

还有

注意在旋转过程中视频是如何被剪切的。

(为了记录,我不拥有播放器中视频的权利。来自这里https://www.youtube.com/watch?v=Q78COTwT7nE

【问题讨论】:

    标签: ios uiwebview youtube-api


    【解决方案1】:

    使用$(window).trigger('resize'); 应该会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-29
      • 2011-09-11
      • 2013-01-19
      • 1970-01-01
      • 2012-12-09
      • 2014-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多