youtube video not working in Webview with anyDensity set to false
<p>On jelly beans android device (also ICS I believe), youtube videos in in an frame inside an android WebView stopped working in our apps many weeks ago: no video (black screen) but can hear sounds and see video controls.
I finally found one clue about what's preventing them from working.
Seems like the following needs to be set in the manifest for the video to work:</p>

<pre><code>android:targetSdkVersion="8"
android:hardwareAccelerated="true"
supports-screens android:anyDensity="false"
</code></pre>

<p>Also on a side note, the video works fine after we click on the full screen youtube button (but I do not want to use fullscreen).</p>

<p>1) and 2) are not an issue for us, we can set those in the manifest (but i wonder why hardware acceleration is required).
But 3) we can't (for different reasons).</p>

<p>Does anyone know why anyDensity sets to false breaks videos and if there is any workaround?</p>

<p>some info about the apk to reproduce the issue:<br>
apk was built with android 3.0<br>
key extract of the manifest:</p>

<pre><code>&lt;uses-sdk android:minSdkVersion="1" android:targetSdkVersion="8"/&gt;
&lt;!-- android:hardwareAccelerated="true" --&gt;
&lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true"&gt;
    &lt;activity android:name=".TestHTML5WebView"
              android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;

&lt;/application&gt;

&lt;supports-screens android:anyDensity="false"/&gt;

...
</code></pre>

<p>html code used for the youtube video:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Test&lt;/title&gt;
&lt;meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi"/&gt;


&lt;script type="text/javascript" charset="utf-8"&gt;
            window.onerror = function(errorMsg) {
                    try {
                            alert(errorMsg);
                    }
                    catch(err) {
                            alert('An expected error occurred. please try again later!');
                    }
            }
&lt;/script&gt;

&lt;style type="text/css" media="screen"&gt;
            body {
                    background: #000;
                    margin: 0;
                    padding: 0;
            }

            .video1 {
                    width: 90%;
                    height: 90%;
                    margin: 0 auto;
            }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class="video1"&gt;
            &lt;iframe width="560" height="315" src="http://www.youtube.com/embed/hH9Kx06oO_0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>to reproduce the issue, you can use the source code from <a href="http://code.google.com/p/html5webview/source/checkout" rel="nofollow">http://code.google.com/p/html5webview/source/checkout</a> (just make sure you update the manifest.xml with the values indicated at the top of this post, targetSdkVersion, hardwareAccelerated, android:anyDensity).</p>

<p>thanks.</p>

<p>Laurent</p>
