Reputation: 149
I created a WebView for YouTube . The URL loads but the videos does not loads.
WebView web = (WebView) findViewById(R.id.web);
web.loadUrl("http://youtube.com");
That problem is now fixed after setting WebChromeClient.
web.setWebChromeClient(new ChromeClient());
Create a new class which extends WebChromeClient
public class ChromeClient extends WebChromeClient{
}
Upvotes: 2
Views: 69
Reputation: 356
The url needs HTTPS not HTTP in order for it to load properly.
https://www.youtube.com/
Upvotes: 0
Reputation: 61
As I found that YouTube is working in default browser used. this workaround to get it working
You have to check first, try the code below
if (url.contains("youtube")) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} else {
webView.loadUrl(url);
}
hope, it helps
Upvotes: 3