I am trying to play a youtube clip in a WebView
inside aFragment
.
It is lodiong fine however when I try and play it I only hear the youtube clip and the video doesn't play. Also I see a blue screen over the webview when I press play. see image:
Also here is my Fragment:
public class WebViewerFragment extends Fragment{
private WebView mWebView;
private String mWebURL;
private ProgressBar mProgressBar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if (container == null)
{
return null;
}
View view = inflater.inflate(R.layout.utube_viewer_layout, container, false);
mWebView = (WebView) view.findViewById(R.id.utube_wv);
mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar_YouTube);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
mWebView.setWebViewClient(new myWebClient());
WebSettings ws = mWebView.getSettings();
ws.setBuiltInZoomControls(true);
ws.setJavaScriptEnabled(true);
ws.setPluginState(PluginState.ON);
ws.setPluginsEnabled(true);
mWebView.loadUrl("http://www.youtube.com/watch?v=LD-67jlsY9I");
}
public class myWebClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
mWebView.setWebViewClient(new myWebClient());
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
view.setVisibility(View.GONE);
mProgressBar.setVisibility(view.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url)
{
view.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(view.GONE);
}
}}