Android – Why Android WebView is not loading youtube HTML5 iframe video

androidwebviewyoutube

I tried the following:

    WebView wv = (WebView) findViewById(R.id.webView1);
    String playVideo= "<html><body><iframe width='200' height='143' src='http://www.youtube.com/embed/JW5meKfy3fY' frameborder='0' allowfullscreen></iframe></body></html>";
    wv.getSettings().setPluginsEnabled(true);
    wv.getSettings().setAllowFileAccess(true);
    wv.getSettings().setPluginState(PluginState.ON);
    wv.getSettings().setBuiltInZoomControls(true);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.loadData(playVideo, "text/html", "utf-8");

I only see thumbnail and then when I click on it the frame turns to black and does not load the video. I'm targeting API 15 and I have internet permission. How could I run the html5 youtube iframe video in Android webview?

Best Answer

You have to put this in your manifest

<application android:hardwareAccelerated="true" ...>
Related Topic