在WebView中嵌入YouTube视频的不尊重全屏设置 [英] Embedded YouTube video in WebView does not respect full screen settings

查看:1190
本文介绍了在WebView中嵌入YouTube视频的不尊重全屏设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是指南显示在这里嵌入视频中的WebView的控制器。

web视图是一个有主题的活动在 Theme.Dialog

嵌入式视频被示出具有缩略图首先在一个活动。我使用 FS = 0 禁用全屏选项。

pressing播放按钮,在HTML5模式下的视频负载(我认为),之后则它不尊重fullsceen设置我设置。

如何禁用在HTML5模式下的全屏幕设置?

我的HTML code是如下:

 公共字符串getHTML(){
        字符串的html =< IFRAME类= \\的YouTube播放器\\的风格= \\边界:0;宽度:100%;高度:95%;填充:0像素;保证金:0像素\\ID = \\YouTube播放器\\式= \\text / html的\\SRC = \\http://www.youtube.com/embed/
                +k8GzqXg2ugA
                +?FS = 0 \\FRAMEBORDER = \\0 \\> \\ N
                +< / IFRAME> \\ N的;
        返回HTML;
    }


解决方案

您需要创建一个新的 WebChromeClient ,覆盖 onShowCustomView(查看视图, WebChromeClient.CustomViewCallback回调) onHideCustomView()

请参阅下面的回答:

http://stackoverflow.com/a/12850816/475472

I am using the the guide displayed over here to embed a video in a WebView controller.

The WebView is inside an Activity which has the the theme Theme.Dialog

The embedded video is shown with the thumbnail first in a Activity. I use fs=0 to disable the fullscreen option.

After pressing the play button, the video loads in HTML5 mode (I think) and then it does not respect the fullsceen setting I've set.

How can I disable the full screen setting in the HTML5 mode?

My HTML code is as follows.

public String getHTML() {
        String html = "<iframe class=\"youtube-player\" style=\"border: 0; width: 100%; height: 95%; padding:0px; margin:0px\" id=\"ytplayer\" type=\"text/html\" src=\"http://www.youtube.com/embed/"
                + "k8GzqXg2ugA"
                + "?fs=0\" frameborder=\"0\">\n"
                + "</iframe>\n";
        return html;
    }

解决方案

You need to create a new WebChromeClient, overriding onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) and onHideCustomView()

See the following answer:

http://stackoverflow.com/a/12850816/475472

这篇关于在WebView中嵌入YouTube视频的不尊重全屏设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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