ExoPlayer在全屏模式下旋转 [英] ExoPlayer rotate in FullScreen

查看:316
本文介绍了ExoPlayer在全屏模式下旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在设备旋转时旋转播放器. 我用它来使播放器全屏显示

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);

我尝试setRotation(90),但是我的视线从角落变小了! 当我尝试更改设备的显示方向以使其全屏显示时,第一个播放器将进入正常的全屏显示模式,然后绘制一半的视图[!

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[!

推荐答案

我自己找到了答案,这是ReactExoPlayerView的全屏集成

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

这篇关于ExoPlayer在全屏模式下旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆