I am playing YouTube videos in webview Android. First I am calling the JavaScript functions for getting the status of the YouTube video. When I get the status one at the only I am visible the webview until that webview is visible gone and loading the webview background.
It works fine, but after getting the YouTube video status I am visible the webview it is visible with black screen and spinner is rotating on that screen. Below is my screen:
Below is my simple code:
final MyJavaScriptInterface myJavaScriptInterface
= new MyJavaScriptInterface(this);
myBrowser.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction");
myBrowser.setWebViewClient(new WebViewClient());
myBrowser.getSettings().setJavaScriptEnabled(true);
myBrowser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
myBrowser.getSettings().setPluginState(WebSettings.PluginState.ON);
myBrowser.setWebChromeClient(new WebChromeClient());
myBrowser.getSettings().setAppCacheEnabled(true);
myBrowser.getSettings().setSaveFormData(true);
myBrowser.setWebChromeClient(new WebChromeClient() {
});
myBrowser.loadUrl("http://Xxxxxxxxxxx/player_android/youtube?videoid=txqiwrbYGrs&st=10&en=20&height=250&width=500&auto=1&ctrl=0&p2p=1");
At that time I click on the webview, the video is played successfully. Without touching the webview, the video is not shown on the screen. How to play the YouTube video in webview?