1

Is there a callback or a way to handle mp4 completion listener in webview.

As Mp4 is not supported in all device. I have to open another activity on completion of a mp4 video.

So how could I now that a video is completed in WebView.I know how to do this using VideoView .

mWebView.setWebViewClient(new WebViewClient() {

   @Override
   public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {

   return true;
   }

   @Override
   public void onPageStarted(WebView view, String url, Bitmap facIcon) {

    }

   @Override
   public void onPageFinished(WebView view, String url) {

    }
});

webview delegate only helps to know that page is fully loaded. Or tell me an alternate to handle onCompletion for MP4. mediaplayer.setOnCompletion only works for VideoView not for WebView.

Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
  • Please refer this link it may help http://stackoverflow.com/questions/15768837/playing-html5-video-on-fullscreen-in-android-webview – Jay Shah Aug 16 '16 at 07:41
  • @JayShah my issue is not to support HTML 5. Issue is to listen for completion listener. when a video is completly seen by a user – Zar E Ahmer Aug 16 '16 at 07:51
  • if you look at the link he has made custom webview client and in that client he supported onCompletionListener for video in webview.You can modify or apply logic as per your requirement. – Jay Shah Aug 16 '16 at 07:54

1 Answers1

0

With a WebView you can bind javascript code with Android code. Take a look at here .

You can set a listener in your HTML video tag and when OnCompletion is called, you can call any code on your Android app.

Hope it helps!

jos
  • 1,070
  • 12
  • 22