package com.example.gsyvideoplayer;

import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.support.v7.app.AppCompatActivity;
import android.transition.Explode;
import android.util.Log;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.RelativeLayout;

import com.example.gsyvideoplayer.adapter.ListNormalAdapter;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ListVideoActivity extends AppCompatActivity {

    @BindView(R.id.video_list)
    ListView videoList;
    @BindView(R.id.activity_list_video)
    RelativeLayout activityListVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // 设置一个exit transition
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
            getWindow().setEnterTransition(new Explode());
            getWindow().setExitTransition(new Explode());
        }
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_video);
        ButterKnife.bind(this);

        final ListNormalAdapter listNormalAdapter = new ListNormalAdapter(this);
        videoList.setAdapter(listNormalAdapter);

        videoList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                int lastVisibleItem = firstVisibleItem + visibleItemCount;
                //大于0说明有播放
                if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                    //当前播放的位置
                    int position = GSYVideoManager.instance().getPlayPosition();
                    //对应的播放列表TAG
                    if (GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)
                            && (position < firstVisibleItem || position > lastVisibleItem)) {
                        //如果滑出去了上面和下面就是否，和今日头条一样
                        GSYVideoPlayer.releaseAllVideos();
                        listNormalAdapter.notifyDataSetChanged();
                    }
                }
            }
        });

    }

    @Override
    public void onBackPressed() {
        if (StandardGSYVideoPlayer.backFromWindowFull(this)) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        GSYVideoPlayer.releaseAllVideos();
    }
}

@@ -630,16 +630,67 @@
 erKnife;
+%0Aimport tv.danmaku.ijk.media.player.IjkMediaPlayer;
 %0A%0Apublic
@@ -877,16 +877,46 @@
 Video;%0A%0A
+%0A    private long pauseTime;%0A%0A
     @Ove
@@ -2802,32 +2802,1110 @@
 essed();%0A    %7D%0A%0A
+    @Override%0A    protected void onPause() %7B%0A        super.onPause();%0A        if (GSYVideoManager.instance().getPlayPosition() %3E= 0 &&%0A                GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) %7B%0A            IjkMediaPlayer ijkMediaPlayer = GSYVideoManager.instance().getMediaPlayer();%0A            if (ijkMediaPlayer != null && ijkMediaPlayer.isPlaying()) %7B%0A                pauseTime = ijkMediaPlayer.getCurrentPosition();%0A                ijkMediaPlayer.pause();%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected void onResume() %7B%0A        super.onResume();%0A        if (GSYVideoManager.instance().getPlayPosition() %3E= 0 &&%0A                GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) %7B%0A            IjkMediaPlayer ijkMediaPlayer = GSYVideoManager.instance().getMediaPlayer();%0A            if (ijkMediaPlayer != null && !ijkMediaPlayer.isPlaying() && pauseTime %3E 0) %7B%0A                ijkMediaPlayer.seekTo(pauseTime);%0A                ijkMediaPlayer.start();%0A                pauseTime = 0;%0A            %7D%0A        %7D%0A    %7D%0A%0A
     @Override%0A  

更新demo，第一种列表中后台暂停和播放视频