Skip to content

Commit 2bc637d

Browse files
committed
改进屏幕旋转逻辑
1 parent 9879c46 commit 2bc637d

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

app/src/main/java/com/dueeeke/dkplayer/widget/videoview/FullScreenIjkVideoView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ protected void startPlay() {
4949
protected void onOrientationPortrait(Activity activity) {
5050

5151
}
52+
53+
@Override
54+
public boolean onBackPressed() {
55+
return false;
56+
}
5257
}

dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,17 @@ protected void onOrientationLandscape(Activity activity) {
131131
*/
132132
protected void onOrientationReverseLandscape(Activity activity) {
133133
if (mCurrentOrientation == REVERSE_LANDSCAPE) return;
134-
if (mCurrentOrientation == PORTRAIT && isFullScreen()) {
134+
if (mCurrentOrientation == PORTRAIT
135+
&& activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
136+
&& isFullScreen()) {
135137
mCurrentOrientation = REVERSE_LANDSCAPE;
136138
return;
137139
}
138140
mCurrentOrientation = REVERSE_LANDSCAPE;
139141
if (!isFullScreen()) {
140142
startFullScreen();
141143
}
144+
142145
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
143146
}
144147

dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,20 @@ public void onVideoSizeChanged(int videoWidth, int videoHeight) {
325325
@Override
326326
public void onWindowFocusChanged(boolean hasFocus) {
327327
super.onWindowFocusChanged(hasFocus);
328-
if (mPlayerConfig.mAutoRotate || isFullScreen()) {
328+
if (hasFocus) {
329+
//重新获得焦点时保持全屏状态
330+
mHideNavBarView.setSystemUiVisibility(FULLSCREEN_FLAGS);
331+
332+
}
333+
334+
if (mPlayerConfig.mAutoRotate || mIsFullScreen) {
329335
if (hasFocus) {
330-
//重新获得焦点时保持全屏状态
331-
mHideNavBarView.setSystemUiVisibility(FULLSCREEN_FLAGS);
332-
mOrientationEventListener.enable();
336+
postDelayed(new Runnable() {
337+
@Override
338+
public void run() {
339+
mOrientationEventListener.enable();
340+
}
341+
}, 800);
333342
} else {
334343
mOrientationEventListener.disable();
335344
}
@@ -403,6 +412,7 @@ public int[] getVideoSize() {
403412

404413
/**
405414
* 旋转视频画面
415+
*
406416
* @param rotation 角度
407417
*/
408418
@Override

0 commit comments

Comments
 (0)