问题
I want to rotate my player when device is rotating. I use this for making my player full screen
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
I try setRotation(90)
but my view lose size,from corners !
When i try just change my device orientation for making full screen, player first player draw half of view,after it go to normal fullscreen mode[!
回答1:
I found the answer myself, this is fullScreen integration for ReactExoPlayerView
private void openFullscreenDialog() {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
((ViewGroup) exoPlayerView.getParent()).removeView(exoPlayerView);
if (playerControlView.getParent() != null) {
((ViewGroup) playerControlView.getParent()).removeView(playerControlView); // <- fix
}
exoPlayerView.addView(playerControlView);
mFullScreenDialog = new Dialog(themedReactContext, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
mFullScreenDialog.addContentView(exoPlayerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mFullScreenDialog.setCancelable(false);
mFullScreenDialog.setOnKeyListener((dialog, keyCode, event) -> {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
if (isFullscreen) {
fullScreenButtonClick();
}
return true;
} else {
return false;
}
});
mFullScreenDialog.show();
}
private void closeFullscreenDialog() {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
((ViewGroup) exoPlayerView.getParent()).removeView(exoPlayerView);
if (playerControlView.getParent() != null) {
((ViewGroup) playerControlView.getParent()).removeView(playerControlView); // <- fix
}
addView(exoPlayerView);
setControls(true);
mFullScreenDialog.dismiss();
}
Hope it will help someone
来源:https://stackoverflow.com/questions/59078850/exoplayer-rotate-in-fullscreen