diff --git a/README.md b/README.md index 80b86acf..3ff1ac93 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' + compile 'com.github.dueeeke:dkplayer:1.4.1' } ``` 或者将library下载并导入项目中使用 diff --git a/app/src/main/java/com/dueeeke/dkplayer/adapter/VideoRecyclerViewAdapter.java b/app/src/main/java/com/dueeeke/dkplayer/adapter/VideoRecyclerViewAdapter.java index 9a378296..7d169aa3 100644 --- a/app/src/main/java/com/dueeeke/dkplayer/adapter/VideoRecyclerViewAdapter.java +++ b/app/src/main/java/com/dueeeke/dkplayer/adapter/VideoRecyclerViewAdapter.java @@ -46,7 +46,7 @@ public void onBindViewHolder(final VideoHolder holder, int position) { holder.ijkVideoView .enableCache() .autoRotate() -// .useAndroidMediaPlayer() + .useAndroidMediaPlayer() .addToPlayerManager() .setUrl(videoBean.getUrl()) .setTitle(videoBean.getTitle()) 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 14f3ae36..c0a44d6d 100644 --- a/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java +++ b/library/src/main/java/com/dueeeke/videoplayer/player/BaseIjkVideoView.java @@ -133,6 +133,7 @@ public BaseIjkVideoView(@NonNull Context context, @Nullable AttributeSet attrs) public BaseIjkVideoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + mAudioManager = (AudioManager) getContext().getApplicationContext().getSystemService(Context.AUDIO_SERVICE); } protected void initPlayer() { @@ -251,9 +252,11 @@ public void release() { if (mMediaPlayer != null) { //启动一个线程来释放播放器,解决列表播放卡顿问题 new Thread(() -> { - mMediaPlayer.reset(); - mMediaPlayer.release(); - mMediaPlayer = null; + if (mMediaPlayer != null) { + mMediaPlayer.reset(); + mMediaPlayer.release(); + mMediaPlayer = null; + } }).start(); mCurrentState = STATE_IDLE; setPlayState(mCurrentState); 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 225b00c6..234cc143 100644 --- a/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java +++ b/library/src/main/java/com/dueeeke/videoplayer/player/IjkVideoView.java @@ -110,11 +110,11 @@ protected void setPlayerState(int playerState) { @Override protected void startPlay() { - super.startPlay(); if (addToPlayerManager) { VideoViewManager.instance().releaseVideoPlayer(); VideoViewManager.instance().setCurrentVideoPlayer(this); } + super.startPlay(); } /** diff --git a/library/src/main/java/com/dueeeke/videoplayer/util/L.java b/library/src/main/java/com/dueeeke/videoplayer/util/L.java index 3d7f4409..1cf386c5 100644 --- a/library/src/main/java/com/dueeeke/videoplayer/util/L.java +++ b/library/src/main/java/com/dueeeke/videoplayer/util/L.java @@ -9,7 +9,7 @@ public class L { - private static final String TAG = "DCPlayer"; + private static final String TAG = "DKPlayer"; public static void d(String msg) {