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