Skip to content

Commit

Permalink
修复悬浮播放授权问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Doikki committed Dec 23, 2017
1 parent 497f3ea commit 227ee2e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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下载并导入项目中使用
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,5 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

public void startFloatWindow(View view) {
ijkVideoView.startFloatWindow();
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;//是否静音
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
*/

public class IjkVideoView extends BaseIjkVideoView {

@Nullable
protected BaseVideoController mVideoController;//控制器
protected ResizeSurfaceView mSurfaceView;
protected ResizeTextureView mTextureView;
protected SurfaceTexture mSurfaceTexture;
Expand Down Expand Up @@ -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());
Expand All @@ -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();
Expand Down

0 comments on commit 227ee2e

Please sign in to comment.