Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flash video not displaying in WebView for Android 3.0.1

I have a simple WebView to display a website with Flash (the Adobe Flash website) -- testing on a Xoom tablet running Android 3.0.1 with newly released Flash 10.2

After referring to every question on stackoverflow, I've set the following:

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.loadUrl("http://www.adobe.com/software/flash/about/");

Both Plugins and JavaScript are enabled for the WebView using getSettings(), yet Flash fails to show up. When I set setPluginState to ON_DEMAND, it shows the correct placeholder for Flash -- yet again, when I tap the item where Flash should be, the Flash disappears (as if the Flash video is failing to render) and only the audio (depending on the Flash content) can be heard.

I've also noticed that I can tap the missing Flash, do a long-hold tap, then tap the top left where the new Flash 'Fullscreen' button SHOULD be and it'll then show up correctly in Fullscreen mode. But when I fall back to the WebView, it again fails to show up and only plays the audio.

Any thoughts are appreciated! Please don't just refer me back to something posted months ago without some details on why I'm referring to a post months before the Android 3.0 release! Thanks again for any help. Great community!

like image 567
Xezuka Avatar asked Mar 21 '11 20:03

Xezuka


4 Answers

So after a week and a half+ of searching high and low, trying different techniques, and just about near ready to throw my tablet out the window, I finally figured it out -- and I'm not too happy how EASY it was to fix; then again, I am!

Remember, this was directed toward the ISSUE of Flash video not loading into the WebView on my Xoom Android 3.0.1 tablet with PluginState ON. Read my question and then the answer. Enjoy!

Step 1: Simply add this to the tag under your Applications Manifest XML

android:hardwareAccelerated="true"

Step 2: Load up your app and enjoy your Flash enabled WebView!

Good luck!

like image 69
Xezuka Avatar answered Nov 01 '22 22:11

Xezuka


webView.setWebChromeClient(new WebChromeClient());

Don't know why but this helped me.

like image 43
narek.gevorgyan Avatar answered Nov 02 '22 00:11

narek.gevorgyan


I have been through the same problem, I can only here audio and can see black screen into WebView. I am using Android 3.2 in Motorola Xoom.

After searching a lot for this solution, finally, I have been able to play video properly in my application.

Solution: I have created another android project with the single Activity containing WebView in it and set above tricks(i.e. android:hardwareAccelerated="true" etc.). Surprisingly, I was able to play the video perfectly into this project!

The strange thing is I was unable to play it with my application's project with the same source code and all. Anyhow it did work for me, don't know how!

like image 3
Bharat Dodeja Avatar answered Nov 02 '22 00:11

Bharat Dodeja


From the API doc here

In your Android manifest file, add the following attribute to the <application> tag to enable hardware acceleration for your entire application:

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

To enable or disable hardware acceleration at the activity level, you can use the android:hardwareAccelerated attribute for the <activity> element.

<application android:hardwareAccelerated="true">
    <activity ... />
    <activity android:hardwareAccelerated="false" />
</application>
like image 1
Mithun Sreedharan Avatar answered Nov 01 '22 23:11

Mithun Sreedharan