I've been trying to play fullscreen video using an iframe but I can't make it work. Here is the code I'm using:
public String getHTML() {
String html= "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" align=\"center\"" +
"src=\"http://www2.whatsupcams.com/wucf_mod_2.php?id=si_bohinj2&autoplay=true\">" +
"</iframe>";
return html;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
this.setContentView(R.layout.activity_webcam);
mWebView = (WebView) this.findViewById(R.id.webView);
mWebView.setBackgroundColor(Color.BLACK);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setFocusable(true);
mWebView.setFocusableInTouchMode(true);
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient());
String data_html = getHTML();
mWebView.loadData(data_html, "text/html", "UTF-8");
}
The video works but the problem is that I can't make the iframe fit the screen, it's either too small or to big for an HD screen. It's too big with the current configuration, looking in stackoverflow I found that:
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
Could do the trick, but it makes the image too small, is there a way to make the iframe use the whole screen? I was thinking something like setting the zoom to fit the screen because when I double tap on the iframe the zoom looks like the appropriate to fill the screen. Thanks.