Android的推出mediplayer从一个web视图视频? [英] Android launch mediplayer for videos from a webview?

查看:150
本文介绍了Android的推出mediplayer从一个web视图视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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;
   }
}

这篇关于Android的推出mediplayer从一个web视图视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆