I get a video in my application from vimeo.com and I play it in a webview. The problem is that when I want to make that webview invisible, it doesn’t work. Only the container disappears but the content is still there, it is inactive(I mean you cannot control it) but it is there. It works fine with a common website, but in this case it doesn’t.
I have tried some of the WebView properties but with no result.
I’m not looking to stop,pause or resume the video in this way, I just want to make all of it invisible.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView)findViewById(R.id.wv);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
//mWebView.loadDataWithBaseURL(null,"<html><body> <iframe id='video' src='http://player.vimeo.com/video/37817858?autoplay=1&api=1'" +
//" width='300px' height='200px' frameborder='0'></iframe></html><body> ", "text/html", "utf-8",null);
mWebView.loadUrl("http://player.vimeo.com/video/37817858");
Button mbtn = (Button)findViewById(R.id.btn);
mbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(mWebView.getVisibility() == View.VISIBLE){
mWebView.setVisibility(View.INVISIBLE);
}
else{
mWebView.setVisibility(View.VISIBLE);
}
}
});
}
How can I do this? 🙂
Use
webView.removeAllViews()to remove all views from WebView