在Mediaplayer中播放的Android Webview视频 [英] Android webview video to play in mediaplayer

查看:444
本文介绍了在Mediaplayer中播放的Android Webview视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个显示带有html标签内容的应用.内容具有HTML5视频标签,可显示来自外部来源的视频.

I'm currently building an app which shows a content with html tags. The content has a HTML5 video tag which shows video from an external source.

通过使用webview.loadDataWithBaseURL(),我加载了html页面. Web视图显示视频以及控件(播放,停止等).我想做的是,当我单击视频时,它将触发android默认的Mediaplayer意向下载并播放视频源,而不是与webview内联播放视频

By using webview.loadDataWithBaseURL(), I load the html page. The webview shows the video along with the controls (play, stop, etc.). What I want to do is when I clicked the video, it will fire the android default mediaplayer intent downloading and playing the video source, not playing the video inline with the webview

通过哪种方式完成此任务?

By which way to achieve this task?

推荐答案

使用WebViewClient shouldOverrideUrlLoading检测点击

webView.setWebViewClient(new MyWebClient());

private class MyWebClient extends WebViewClient {

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

这篇关于在Mediaplayer中播放的Android Webview视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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