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:
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!
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 ?
Thanks @Adnan Mulla for answering, your solutions works has an issue/bug
Issue: There is bug in https://github.com/droid28/VimeoVideo It does not stop audio even after finishing the activity.
Solution: One must destroy WebView
in onDestroy()
@Override
protected void onDestroy() {
super.onDestroy();
mWebView.destroy();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With