package com.example.gsyvideoplayer.switchplay;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;


public class SwitchUtil {

    private static SwitchVideo sSwitchVideo;

    public static void optionPlayer(final SwitchVideo gsyVideoPlayer, String url, boolean cache, String title) {
        //增加title
        gsyVideoPlayer.getTitleTextView().setVisibility(View.GONE);
        //设置返回键
        gsyVideoPlayer.getBackButton().setVisibility(View.GONE);
        //设置全屏按键功能
        gsyVideoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gsyVideoPlayer.startWindowFullscreen(gsyVideoPlayer.getContext(), false, true);
            }
        });
        //是否根据视频尺寸，自动选择竖屏全屏或者横屏全屏
        gsyVideoPlayer.setAutoFullWithSize(true);
        //音频焦点冲突时是否释放
        gsyVideoPlayer.setReleaseWhenLossAudio(false);
        //全屏动画
        gsyVideoPlayer.setShowFullAnimation(false);
        //小屏时不触摸滑动
        gsyVideoPlayer.setIsTouchWiget(false);

        gsyVideoPlayer.setSwitchUrl(url);

        gsyVideoPlayer.setSwitchCache(cache);

        gsyVideoPlayer.setSwitchTitle(title);
    }


    public static void savePlayState(SwitchVideo switchVideo) {
        sSwitchVideo = switchVideo.saveState();
    }

    public static void clonePlayState(SwitchVideo switchVideo) {
        switchVideo.cloneState(sSwitchVideo);
    }

    public static void release() {
        sSwitchVideo = null;
    }
}

@@ -60,109 +60,83 @@
 oid.
-app.Activity;%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.view.View
+view.View;%0A%0Aimport com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener
 ;%0A%0A%0A
@@ -206,16 +206,80 @@
 chVideo;
+%0A    private static GSYMediaPlayerListener sMediaPlayerListener;
 %0A%0A    pu
@@ -1401,22 +1401,66 @@
 tate();%0A
+        sMediaPlayerListener = switchVideo;%0A
     %7D%0A
-
 %0A    pub
@@ -1613,28 +1613,172 @@
         
-sSwitchVideo
+if (sMediaPlayerListener != null) %7B%0A            sMediaPlayerListener.onAutoCompletion();%0A        %7D%0A        sSwitchVideo = null;%0A        sMediaPlayerListener
  = null;

fix 2280