我有一个web视图,如果用户点击一个链接,它在同一个web视图中打开(我控制研究与shouldOverrideUrlLoading()),但如果它是一个视频链接(MP4,3GP)没有启动媒体播放器以再现视频(因为它在正常浏览器应用程序)。 如何O强制媒体播放器启动时,一个视频链接被点击的WebView里面?
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?
谢谢!
在这种情况下,您将需要执行一个Intent加载外部视频网址。 这也便利地允许用户返回到previous视图(活性)没有任何问题。见下面code ....
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;
}
}