From 497f3ea13f99c59134d5dda66cf7a71026fabd8b Mon Sep 17 00:00:00 2001 From: Dueke Date: Sat, 23 Dec 2017 22:21:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E2=80=9C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E6=97=B6=E4=B8=8D=E8=83=BD=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E6=BB=91=E5=87=BA=E5=B1=8F=E5=B9=95=E7=9A=84?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E2=80=9D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../dkplayer/adapter/VideoRecyclerViewAdapter.java | 2 +- .../com/dueeeke/videoplayer/player/BaseIjkVideoView.java | 9 ++++++--- .../com/dueeeke/videoplayer/player/IjkVideoView.java | 2 +- .../src/main/java/com/dueeeke/videoplayer/util/L.java | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) 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) {