YouTube视频嵌入在Android的web视图没有在SINGLE_COLUMN布局玩 [英] Youtube videos embedded in Android Webview don't play in SINGLE_COLUMN layout

查看:184
本文介绍了YouTube视频嵌入在Android的web视图没有在SINGLE_COLUMN布局玩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载一些HTML数据到Android的web视图。这些数据是在串是从Web服务加载和HTML可以包含嵌入的YouTube视频,我想嵌入内联,使播放的形式。

I am trying to load some HTML data into Android Webview. The data is in the form of string that is loaded from a web service and the HTML can contain embedded youtube videos which I want to embed inline and make playable.

一切工作正常与 LayoutAlgorithm.NORMAL 。但是,当我使用 SINGLE_COLUMN 布局算法,Youtube的视频显示为无法再发挥黑匣子。我需要一个单独的列格式的图像HTML的溢出内部的WebView宽度正常模式。这是我的code配置web视图。

Everything works fine with LayoutAlgorithm.NORMAL. But when I use the SINGLE_COLUMN layout algorithm, the Youtube videos show up as black boxes that cannot be played anymore. I need a single column format as the images inside the HTML overflow the webview width in NORMAL mode. Here's my code to configure the webview.

// Set maximum image width to fit screen
contentWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

// Make non focusable to prevent links from being selectable.
contentWebView.setFocusableInTouchMode(false);
contentWebView.setFocusable(false);

// Enable HTML5 video
contentWebView.getSettings().setJavaScriptEnabled(true);
contentWebView.getSettings().setPluginState(PluginState.ON);
contentWebView.setWebChromeClient(new WebChromeClient() {
});

是否有可能以某种方式使视频播放与 SINGLE_COLUMN 布局或手动模拟单列布局,同时运用正常布局算法?任何其他的想法?

Is it possible to somehow make the videos playable with SINGLE_COLUMN layout or emulate the single column layout manually while applying the NORMAL layout algorithm? Any other ideas?

推荐答案

LayoutAlgorithm.SINGLE_COLUMN - 是去precated上 Google代码。 你如果可以改变元素的宽度/高度在你的HTML字符串。

LayoutAlgorithm.SINGLE_COLUMN - is deprecated on google developers. You have to change width/height of elements in your html string if you can.

在我来说,我代替所有高度=宽度= - 和它的伟大工程没有任何setLayoutAlgorithm()设置。 或者试试这个解决方案

In my case i replace all height="", width="" - and it works great without any setLayoutAlgorithm() settings. Or try this solution

这篇关于YouTube视频嵌入在Android的web视图没有在SINGLE_COLUMN布局玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆