-1

I want to load the youtube video in Web-view, that opens after login page in web-view.

Is it possible to load inner Youtube video in Web-view?

webView = (WebView) findViewById(R.id.webview); 
webView.loadUrl("");
webView.getSettings().setJavaScriptEnabled(true);

webView.clearCache(false);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);

webView.setWebViewClient(new MyOwnWebViewClient());
class MyOwnWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
zaptech
  • 131
  • 1
  • 15
  • 1
    possible duplicate of [http://stackoverflow.com/questions/14156411/loading-youtube-video-through-i-frame-in-android-webview](http://stackoverflow.com/questions/14156411/loading-youtube-video-through-i-frame-in-android-webview) [http://stackoverflow.com/questions/8475707/youtube-video-in-webview-doesnt-load](http://stackoverflow.com/questions/8475707/youtube-video-in-webview-doesnt-load) – sud Dec 02 '15 at 10:11

2 Answers2

0

You can try some of things i did when i was working on one the similar kind of project. Here is the link to my question which has the code and other things i did.

Community
  • 1
  • 1
anshul
  • 982
  • 1
  • 11
  • 33
0

Please check this it worked for me in inner Youtube video of youtube.

if (url.endsWith(".mp3")) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.parse(url), "audio/*");
                    view.getContext().startActivity(intent);
                    return true;
                } else if (url.endsWith(".mp4") || url.endsWith(".3gp")) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.parse(url), "video/*");
                    view.getContext().startActivity(intent);
                    return true;
                } else {
                    return super.shouldOverrideUrlLoading(view, url);
                }