After 2 days, looking for a lite way to do it, here is, for me, the best and simpliest solution :
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) {
}
}
}
}
Hope this help...
PS : Works with YouTube