From d9c3e178336dbdf525d705e0e03d0aeaed2bd6bc Mon Sep 17 00:00:00 2001 From: dueeeke Date: Wed, 23 Jan 2019 00:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=B1=8F=E5=B9=95=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dueeeke/dkplayer/activity/pip/PIPActivity.java | 3 +-- .../com/dueeeke/videoplayer/player/BaseIjkVideoView.java | 8 +++++++- .../java/com/dueeeke/videoplayer/player/IjkVideoView.java | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/dueeeke/dkplayer/activity/pip/PIPActivity.java b/app/src/main/java/com/dueeeke/dkplayer/activity/pip/PIPActivity.java index 2cdfa071..fa86d858 100644 --- a/app/src/main/java/com/dueeeke/dkplayer/activity/pip/PIPActivity.java +++ b/app/src/main/java/com/dueeeke/dkplayer/activity/pip/PIPActivity.java @@ -19,7 +19,7 @@ public class PIPActivity extends AppCompatActivity{ private PIPManager mPIPManager; // private static final String URL = "rtmp://live.hkstv.hk.lxdns.com/live/hks"; - private static final String URL = "http://220.161.87.62:8800/hls/0/index.m3u8"; + private static final String URL = "http://mov.bn.netease.com/open-movie/nos/flv/2017/01/03/SC8U8K7BC_hd.flv"; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -34,7 +34,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mPIPManager = PIPManager.getInstance(); IjkVideoView ijkVideoView = mPIPManager.getIjkVideoView(); StandardVideoController controller = new StandardVideoController(this); - controller.setLive(); ijkVideoView.setVideoController(controller); if (mPIPManager.isStartFloatWindow()) { mPIPManager.stopFloatWindow(); diff --git a/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java b/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java index 8467f674..ca16612b 100644 --- a/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java +++ b/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java @@ -80,8 +80,11 @@ public abstract class BaseIjkVideoView extends FrameLayout implements MediaPlaye * 加速度传感器监听 */ protected OrientationEventListener mOrientationEventListener = new OrientationEventListener(getContext()) { // 加速度传感器监听,用于自动旋转屏幕 + private long mLastTime; @Override public void onOrientationChanged(int orientation) { + long currentTime = System.currentTimeMillis(); + if (currentTime - mLastTime < 300) return;//300毫秒检测一次 if (mVideoController == null) return; Activity activity = PlayerUtils.scanForActivity(mVideoController.getContext()); if (activity == null) return; @@ -92,6 +95,7 @@ public void onOrientationChanged(int orientation) { } else if (orientation >= 70 && orientation <= 90) { //屏幕右边朝上 onOrientationReverseLandscape(activity); } + mLastTime = currentTime; } }; @@ -115,7 +119,9 @@ protected void onOrientationPortrait(Activity activity) { */ protected void onOrientationLandscape(Activity activity) { if (mCurrentOrientation == LANDSCAPE) return; - if (mCurrentOrientation == PORTRAIT && isFullScreen()) { + if (mCurrentOrientation == PORTRAIT + && activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE + && isFullScreen()) { mCurrentOrientation = LANDSCAPE; return; } diff --git a/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java b/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java index a8b4159e..bdd351bc 100644 --- a/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java +++ b/dkplayer-java/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java @@ -328,10 +328,9 @@ public void onWindowFocusChanged(boolean hasFocus) { if (hasFocus) { //重新获得焦点时保持全屏状态 mHideNavBarView.setSystemUiVisibility(FULLSCREEN_FLAGS); - } - if (mPlayerConfig.mAutoRotate || mIsFullScreen) { + if (isInPlaybackState() && (mPlayerConfig.mAutoRotate || mIsFullScreen)) { if (hasFocus) { postDelayed(new Runnable() { @Override