views:

859

answers:

3

I have a webview, if the user clicks on a link, it opens in the same webview (I controll that with shouldOverrideUrlLoading()) but if it is a video link (mp4, 3gp) it does not launch the media player to reproduce the video (as it does in the normal browser app). How o force the media player to launch when a video link is clicked inside a webview?

Thanks!

A: 

I meant that when the url is pointing to a video file, I'd like the mediaplayer to reproduces it. Every other URL is being handled by the webview, and that is OK but when the URL is pointing to a video file, nothing happens when I try to load that url.

yusev segunpta
A: 

First of all, as far as I know, Android supports rtsp playback only. So onclick of the link, give document.location.href="rtsp://your video url";

Bennet
A: 

In this case you will need to execute an Intent to load an external video url. This also conveniently allows user to return to the previous view ( activity ) without any problem. See code below....

 /*-----------------------------------------------------------------------------------------------
 *  WebViewClientHandler() allows for overriding default phone web browser so we can load in gui
 *----------------------------------------------------------------------------------------------*/
private class WebViewClientHandler extends WebViewClient {
  public boolean shouldOverrideUrlLoading(WebView view, String url) {

    Uri uri = Uri.parse("http://YOUTSTREAM.FLV");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    startActivity(intent);
        return true;
   }
}
Psypher