如何使用自己的写的播放器 播放webview 中视频和音乐?
WebView.setDownloadListener(new DownloadListener(){------------})
实现onDownloadStart()的方法里写楼上的代码
public void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimetype, long contentLength) {
if (contentDisposition == null
|| !contentDisposition.regionMatches(true, 0, "attachment", 0, 10)) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(url);
intent.setDataAndType(uri, mimetype);
ResolveInfo info = getPackageManager().resolveActivity(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
ComponentName myName = getComponentName();
if (!myName.getPackageName().equals(info.activityInfo.packageName)
|| !myName.getClassName().equals(info.activityInfo.name)) {
try {
//此处链接自己写的播放器
localPlayerIntent = getLocalPlayerInteng(uri);
startActivity(localPlayerIntent);
return;
} catch (ActivityNotFoundException ex) {
}
}
} else {
//下载
}
}
}