diff --git a/README.md b/README.md index 3ff1ac93..e01c42c7 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Step 1.Add it in your root build.gradle at the end of repositories: Step 2. Add the dependency dependencies { - compile 'com.github.dueeeke:dkplayer:1.4.1' + compile 'com.github.dueeeke:dkplayer:1.4.2' } ``` 或者将library下载并导入项目中使用 diff --git a/app/build.gradle b/app/build.gradle index 77835311..27473ef3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.dueeeke.dkplayer" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 8 - versionName "1.4" + versionCode 10 + versionName "1.4.2" } diff --git a/app/src/main/java/com/dueeeke/dkplayer/activity/LivePlayerActivity.java b/app/src/main/java/com/dueeeke/dkplayer/activity/LivePlayerActivity.java index d33f6419..533e54e8 100644 --- a/app/src/main/java/com/dueeeke/dkplayer/activity/LivePlayerActivity.java +++ b/app/src/main/java/com/dueeeke/dkplayer/activity/LivePlayerActivity.java @@ -103,6 +103,5 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { public void startFloatWindow(View view) { ijkVideoView.startFloatWindow(); - finish(); } } diff --git a/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java b/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java index c0a44d6d..18ab7e5b 100644 --- a/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java +++ b/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.OrientationEventListener; +import android.view.WindowManager; import android.widget.FrameLayout; import com.danikula.videocache.CacheListener; @@ -35,6 +36,8 @@ public abstract class BaseIjkVideoView extends FrameLayout implements BaseVideoController.MediaPlayerControl, MediaEngineInterface { protected BaseMediaEngine mMediaPlayer;//播放引擎 + @Nullable + protected BaseVideoController mVideoController;//控制器 protected VideoListener listener; protected int bufferPercentage;//缓冲百分比 protected boolean isMute;//是否静音 @@ -78,7 +81,8 @@ public abstract class BaseIjkVideoView extends FrameLayout implements BaseVideoC @Override public void onOrientationChanged(int orientation) { - Activity activity = WindowUtil.scanForActivity(getContext()); + if (mVideoController == null) return; + Activity activity = WindowUtil.scanForActivity(mVideoController.getContext()); if (activity == null) return; if (orientation >= 340) { //屏幕顶部朝上 if (mAlwaysFullScreen || isLockFullScreen || !mAutoRotate) return; @@ -338,6 +342,8 @@ private void startBackgroundService() { intent.putExtra(KeyUtil.ENABLE_CACHE, isCache); intent.putExtra(KeyUtil.ACTION, Constants.COMMAND_START); getContext().getApplicationContext().startService(intent); + Activity activity = WindowUtil.scanForActivity(getContext()); + if (activity != null) activity.finish(); } /** diff --git a/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java b/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java index 234cc143..94d7a312 100644 --- a/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java +++ b/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java @@ -34,9 +34,6 @@ */ public class IjkVideoView extends BaseIjkVideoView { - - @Nullable - protected BaseVideoController mVideoController;//控制器 protected ResizeSurfaceView mSurfaceView; protected ResizeTextureView mTextureView; protected SurfaceTexture mSurfaceTexture; @@ -221,7 +218,8 @@ public void release() { @Override public void startFullScreen() { - Activity activity = WindowUtil.scanForActivity(getContext()); + if (mVideoController == null) return; + Activity activity = WindowUtil.scanForActivity(mVideoController.getContext()); if (activity == null) return; if (isFullScreen) return; WindowUtil.hideSystemBar(getContext()); @@ -234,12 +232,13 @@ public void startFullScreen() { contentView.addView(playerContainer, params); orientationEventListener.enable(); isFullScreen = true; - if (mVideoController != null) mVideoController.setPlayerState(PLAYER_FULL_SCREEN); + mVideoController.setPlayerState(PLAYER_FULL_SCREEN); } @Override public void stopFullScreen() { - Activity activity = WindowUtil.scanForActivity(getContext()); + if (mVideoController == null) return; + Activity activity = WindowUtil.scanForActivity(mVideoController.getContext()); if (activity == null) return; if (!isFullScreen) return; if (!mAutoRotate) orientationEventListener.disable();