android - ExoPlayer rotate in FullScreen
问题描述
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[!
解决方案
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
推荐阅读
- java - 如何在基于 webview 的应用程序中将用户登录数据存储在应用程序数据中?
- node.js - 大的post请求使Nodejs服务器堆内存不足
- laravel - 不能使用 Conekta\Object 作为对象,因为“对象”是一个特殊的类名
- java - Gradle 参与 Android 构建过程
- azure-devops - 如何在多个目录中模式匹配不同的文件
- ruby-on-rails - 在不重启服务的情况下刷新 Ruby on Rails DNS 缓存
- css - 如何将相同的样式应用于具有相同父路径的不同深层选择器
- php - 需要帮助将 div 样式添加到 php echo 语句
- python-3.x - Discord.py 重写 - YoutubeDL 播放音乐的来源是什么?
- c# - 如何从 IExceptionFilter.OnException() 返回源视图