I need to display in webView in custom dialog. Anyway, I can load youtube site, and navigate trought videos, but when I want to play some video and when I click play nothing happens. Video just get orange flash like it is selected, but doesnt start loading and playing. Whats the problem?
I found tutorial on net, and trying to modify it. Here is the code:
dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog);
pd = (ProgressBar) dialog.findViewById(R.id.web_view_progress_bar);
webview = (WebView) dialog.findViewById(R.id.web_view);
webview.getSettings().setPluginState(PluginState.ON);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (progress < 100 && pd.getVisibility() == ProgressBar.GONE) {
pd.setVisibility(ProgressBar.VISIBLE);
}
pd.setProgress(progress);
if (progress == 100) {
pd.setVisibility(ProgressBar.GONE);
}
}
});
webview.setWebViewClient(new YoutubeWebViewClient());
//shouldOverrideUrlLoading(webview, this.getUrl());
webview.loadUrl(this.getUrl());
dialog.show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && webview.canGoBack()) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private class YoutubeWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Help?
UPDATE:
I've tried this to do in other way, but again problems...
Im trying to embed youtube html5 player in webView. I only get back field without a youtube video. In right corner of webView is the youtube sign, and thats all of it. Dont have android phone, testing app on android x86 platform. is that a problem?
help :) dont care about a way of implementation, i just need this to work ^^