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 cb99b48 commit 497f3ea
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 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'
compile 'com.github.dueeeke:dkplayer:1.4.1'
}
```
或者将library下载并导入项目中使用
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/com/dueeeke/videoplayer/util/L.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 497f3ea

Please sign in to comment.