在我的应用程序中,webviews中有webviews和视频。但是视频没有播放.. 以下是webview代码片段。
Web.setWebViewClient(new myWebClient());
Web.getSettings().setJavaScriptEnabled(true);
Web.getSettings().setPluginsEnabled(true);
Web.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
答案 0 :(得分:2)
2天之后,寻找一种轻松的方式,对我来说,这是最好和最简单的解决方案:
public CustomViewCallback mCustomViewCallback;
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout) {
FrameLayout customViewContainer = (FrameLayout) view;
mCustomViewCallback = callback;
if (customViewContainer.getFocusedChild() instanceof VideoView) {
VideoView customVideoView = (VideoView) customViewContainer.getFocusedChild();
try {
Field mUriField = VideoView.class.getDeclaredField("mUri");
mUriField.setAccessible(true);
Uri uri = (Uri) mUriField.get(customVideoView);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "video/*");
mActivity.startActivity(intent);
new Handler().post(new Runnable() {
@Override
public void run() {
mCustomViewCallback.onCustomViewHidden();
}
});
} catch (Exception e) {
}
}
}
}
希望这有帮助...... PS:与YouTube合作