Question

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 Intentto 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.

Pas de solution correcte

Autres conseils

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 :)

@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();
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top