How to response to full screen button in websites that has videos

Posted by Pinhassi on Stack Overflow See other posts from Stack Overflow or by Pinhassi
Published on 2012-10-09T06:28:02Z Indexed on 2012/10/22 5:01 UTC
Read the original article Hit count: 514

I use webview to play videos from varios sites, some of them have a full screen button

enter image description here

I would like the webview to respond to the full screen button.

If I set webSettings.setUseWideViewPort(false); then video get stuck when clicking the full screen button and I can see the following error on the logcat:

10-09 08:32:27.970: D/gralloc(31814): unmmap  pid(1876), vaddr(0x589dc000)
10-09 08:32:27.970: E/gralloc(31814): [GR_MD] unmapping from 0x5786c000, size=33427456
10-09 08:32:27.970: D/gralloc(31814): unmmap  pid(1876), vaddr(0x5a9fb000)
10-09 08:32:27.970: E/gralloc(31814): [GR_MD] unmapping from 0x5984d000, size=33427456
10-09 08:32:27.975: D/gralloc(31814): unmmap  pid(1876), vaddr(0x5e616000)
10-09 08:32:27.975: E/gralloc(31814): [GR_MD] unmapping from 0x5d42a000, size=33427456

I'm using Android 4.0.1, here is my code:

setWebViewSettings(mVideoWebView);
String data_html = "<!DOCTYPE HTML> <html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://opengraphprotocol.org/schema/\" xmlns:fb=\"http://www.facebook.com/2008/fbml\"> <head></head> <body style=\"margin:0 0 0 0; padding:0 0 0 0;\"> <iframe src=\"http://www.dailymotion.com/embed/video/xu4vre\" width=\"300\" height=\"162"\" frameborder=\"0\"></iframe> </body> </html> ";
mVideoWebView.loadData(data_html, "text/html", null);


public static void setWebViewSettings(WebView webview) {
    WebSettings webSettings = webview.getSettings();
    webSettings.setPluginState(PluginState.ON);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setLoadWithOverviewMode(false); // zoom y/n
    webSettings.setUseWideViewPort(true); // true = like desktop
    webSettings.setPluginsEnabled(true);

    //webSettings.setAllowContentAccess(true);
    webSettings.setAllowFileAccess(true);
    //webSettings.setAllowFileAccessFromFileURLs(true);
    //webSettings.setAllowUniversalAccessFromFileURLs(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setDomStorageEnabled(true);
}

© Stack Overflow or respective owner

Related posts about android

Related posts about webview