ExoPlayer rotate in FullScreen

北战南征 提交于 2019-12-24 23:37:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!