我想在设备旋转时旋转播放器。 我用它来使播放器全屏显示
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
我尝试setRotation(90)
,但是我的视线从角落消失了!
当我尝试更改设备的显示方向以使其全屏显示时,第一个播放器会进入正常的全屏模式,然后才吸引一半的视线[!
答案 0 :(得分:1)
我自己找到了答案,这是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();
}
希望它将对某人有所帮助