【发布时间】:2019-02-23 16:02:42
【问题描述】:
Youtube 自动播放标签在 Android Webview iframe 中不起作用。 怎么去掉cc标签?
HTML 需要在 webview 中加载:
<!DOCTYPE html>
<html>
<style>
.center{
position: absolute;
margin: auto auto;
right: 0;
left: 0;
bottom: 0;
top: 0;
}
</style>
<body style="background:#000">
<iframe id="videoContainer" class="center" width="100%" height="300"
src="https://www.youtube.com/embed/5jnqWIlaLyA?rel=0&controls=1&showinfo=0&autoplay=1"
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>
</iframe>
</body>
</html>
在网站上运行相同的代码。
Content 变量保存上面提到的 html。 当前的 Android 代码:
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAppCacheEnabled(false);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
view.loadDataWithBaseURL(null, content, "text/html", "utf8", view.getUrl());
【问题讨论】:
标签: java android iframe webview youtube