android - iFrame allowFullScreen 属性在 Android WebView 上不起作用

标签 android iframe webview youtube fullscreen

我需要在我的 Android 项目中显示来自 YouTube 的视频列表,当我点击一个视频时,它应该以全屏模式启动。我使用了其他主题中建议的 WebView 和来自 html 的 iFrame,但“allowFullScreen”属性不起作用。

我尝试了 allowFullScreen, allowFullScreen = "true", allowFullScreen = allowFullScreen 方式。

String frameVideo = "<html><body><iframe width=\"300\" height=\"300\" src=\"https://www.youtube.com/embed/47yJ2XCRLZs\" scrolling=\"no\" frameborder=\"0\" allowFullScreen=\"allowFullScreen\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\"></iframe></body></html>";

    for(int i=0; i<number_of_videos; i++){
        video = new WebView(this);
        video.getSettings().setJavaScriptEnabled(true);
        video.getSettings().setPluginState(WebSettings.PluginState.ON);
        video.loadData(frameVideo, "text/html", "utf-8");
        video.setWebChromeClient(new WebChromeClient());
        video.setId(i);
        video.setPadding(0, 0, 0, 0);
        video.setLayoutParams(new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, 900));
        root.addView(video);
    }

我会避免使用 YouTube API。有什么建议吗?

最佳答案

不要使用 allowFullScreen="allowFullScreen"

<iframe 
width="300" 
height="300" 
src="https://www.youtube.com/embed/47yJ2XCRLZs" 
scrolling="no" 
allowFullScreen > 

allowFullScreen 没有任何值

关于android - iFrame allowFullScreen 属性在 Android WebView 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44232279/

相关文章:

android - Android 上的 HSV 转换不准确

javascript - 在 iframe 中访问 jqgrid

javascript - 在 Ember 中捕获 iframe 加载事件

javascript - Android - ProGuard 引起所有 JavascriptInterface 使用的警告

android - 映射鼠标右键以在 Jelly Bean 中向后遍历

android - 找不到符号类数据绑定(bind) impl

java - 我正在集成一个 android API,在以下情况下一直无法生成 xwsse token

javascript - iframe如何访问chrome扩展中的父窗口

html - Android webview单选按钮和复选框样式

ios - 从 WebView 中的链接打开 Mobile Safari