Reputation: 3237
In a WebView
, I'm trying to load a html5 page where I embed a <video>
but is there any way I can detect when the user selects the play button or the video starts playing?
Right now is when I play the video, default is it fires an Intent
to open Android's default player, I don't want it to fire an Intent, I want to use a Dialog
and play it there. If anybody can give an idea. Thanks.
Upvotes: 2
Views: 2572
Reputation: 9
@Override
public void onCreate(Bundle savedInstanceState) {
....
mywebviewer = (WebView) findViewById(R.id.mywebviewer);
WebSettings webSettings = mywebviewer.getSettings();
webSettings.setJavaScriptEnabled(true);
mywebviewer.loadUrl("https://www.youtube.com");
mywebviewer.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
if (mywebviewer.canGoBack()) {
mywebviewer.goBack();
} else {
super.onBackPressed();
}
}
Upvotes: 0
Reputation: 43
I do it in this way:
boolean videoPlay=false;
webView.setWebChromeClient(new WebChromeClient() {
@Override
public Bitmap getDefaultVideoPoster() {
super.getDefaultVideoPoster();
videoPlay=true;
Log.d("vplayyyyyyyy",String.valueOf(videoPlay));
return null;
}
});
hope this help :)
Upvotes: 0