如何使用自己的寫的播放器 播放webview 中視頻和音樂? - 移動平臺 / Andro...
如何使用自己的寫的播放器 播放webview 中視頻和音樂?
WebView.setDownloadListener(new DownloadListener(){------------})
實現(xiàn)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 {
//下載
}
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。