package com.hainaos.vc.CustomJzvd;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;

import cn.jzvd.JzvdStd;


public class JzvdStdAssert extends JzvdStd {
    private onVideoCompletionListener onVideoCompletionListener;
    private ScreenOrientationChangeListener changeListener;
    private GotoFullScreenListener gotoFullScreenListener;

    public JzvdStdAssert(Context context) {
        super(context);
    }

    public JzvdStdAssert(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public void onPrepared() {
        Log.e("onStateChanged", "onPrepared");
        state = STATE_PREPARED;
        if (!preloading) {
            mediaInterface.start();
            preloading = false;
        }
        onStatePlaying();
    }


    @Override
    public void onCompletion() {
        super.onCompletion();
        onVideoCompletionListener.onVideoComplet();
        Log.e("onStateChanged", "onCompletion");
    }

    public void setOnCompletionListener(onVideoCompletionListener listener) {
        this.onVideoCompletionListener = listener;
    }

    public void setScreenOrientationChangeListener(ScreenOrientationChangeListener listener) {
        this.changeListener = listener;
    }

    public void setGotoFullScreenListener(GotoFullScreenListener listener) {
        this.gotoFullScreenListener = listener;
    }

    @Override
    public void gotoNormalScreen() {
        super.gotoNormalScreen();
        changeListener.onOrientationChange();
    }

    @Override
    public void gotoFullscreen() {
        super.gotoFullscreen();
        gotoFullScreenListener.onGotoFullScreen();
    }

    //视频播放完成回调
    public interface onVideoCompletionListener {
        void onVideoComplet();
    }

    //退出全屏回调
    public interface ScreenOrientationChangeListener {
        void onOrientationChange();
    }

    //进入全屏回调
    public interface GotoFullScreenListener {
        void onGotoFullScreen();
    }

}
