4

I've recently created a mobile web site in which there are several iframe embeds from Vimeo. Now, in the android browser with flash this works pretty well, but when I try to cram it into a WebView for a pseudo-app, the videos won't play. I've read a lot of threads on the issue and this is the code I've got so far:

WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setJavaScriptEnabled(true);

if (Build.VERSION.SDK_INT < 8) {
    wv.getSettings().setPluginsEnabled(true);
} else {
    wv.getSettings().setPluginState(PluginState.ON);
}
wv.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
wv.loadUrl("myurl.here");

The page loads fine and everything works, except for the video playback. All I get is a black rectangle that doesn't respond to anything.

The video iframes I'm trying to play all look like this: <iframe src='http://player.vimeo.com/video/<VIDEO ID HERE>?title=0&byline=0&portrait=0' width='100%' height='auto' frameborder='0'></iframe>

I've also tried enabling hardware acceleration for the app, but this causes an entirely new problem. Upon starting the app this is all that shows (tested on a galaxy nexus): https://i.stack.imgur.com/RJyHQ.png

Flash is installed on the phone, and loading the web page normally through the browser works fine.

I've been googling this all day and I'm still just as stuck as I was when I started trying to figure it out. I'm starting to think this isn't possible at all.

UPDATE: Borrowed a xoom tablet running android 3.2, the video plays fine with hardware acceleration enabled. I still get the weird rendering thing on the nexus though, so it doesn't fix the issue completely.

1 Answers1

0

In case anyone finds this, I found an answer that might help here.

You have to add this code before you load the WebView:

wv.setWebChromeClient(new WebChromeClient() {
});

Example usage:

WebView wv;

wv.setWebChromeClient(new WebChromeClient() {
});

wv.loadUrl("http://www.example.com/");

And make sure you include:

android:hardwareAccelerated="true"

in the <manifest> tag of AndroidManifest.xml (only applies to API 11 or higher)

Community
  • 1
  • 1
Kayenzed
  • 1
  • 2