scientiffic scientiffic - 1 month ago 26
Android Question

Problems with Vimeo Player in Android App's WebView

In my Android app, I created a WebView to play Vimeo videos. When I load the activity, the correct preview of the vimeo video appears, but when I attempt to play it, I get the following screen:

enter image description here

Sometimes the audio from the video plays, but I never get the video. Here is what I have in my activity:

if(mediaURL.toLowerCase().contains("vimeo")){
Log.d(TAG, "adding viemo");
final WebView vimeoPlayer = new WebView(MediaPreview.this);
vimeoPlayer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
vimeoPlayer.getSettings().setJavaScriptEnabled(true);
vimeoPlayer.getSettings().setLoadWithOverviewMode(true);
vimeoPlayer.getSettings().setUserAgentString("Android Mozilla/5.0 AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
vimeoPlayer.setWebChromeClient(new WebChromeClient());
vimeoPlayer.setWebViewClient(new WebViewClient());
vimeoPlayer.getSettings().setAppCacheEnabled(true);
vimeoPlayer.getSettings().setDomStorageEnabled(true);
vimeoPlayer.getSettings().setPluginState(PluginState.ON);
vimeo_url = mediaURL + "?player_id=player&title=0&byline=0&portrait=0&api=1&maxheight=480&maxwidth=800";
Log.d(TAG, "vimeo_url: " + vimeo_url);
vimeoPlayer.loadUrl(vimeo_url);
// vimeoPlayer.loadDataWithBaseURL("", vimeo_url, "text/html", "UTF-8", null);
mediaHolder.addView(vimeoPlayer);;
}


I haven't seen any definitive examples of working Vimeo players in Android apps, so if anyone has gotten this to work, would greatly appreciate your help!

Answer

Everything looks pretty good to me not sure why it won't play for you, have you checked this out : https://github.com/droid28/VimeoVideo ?