package com.xunao.effectdemo.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Toast;

import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import com.xunao.effectdemo.R;
import com.xunao.effectdemo.utils.SoundPoolUtil;

/**
 * author : 程中强
 * e-mail : 740479946@qq.com
 * date : 2022/9/1616:21
 * desc :
 * version: 1.0
 */
public class VideoPreviewPlay extends StandardGSYVideoPlayer {

	private boolean isFinish = false;
	private SoundPoolUtil soundPoolUtil;

	public void setIsFinish(boolean isFinish){
		this.isFinish = isFinish;
	}
	public VideoPreviewPlay(Context context, Boolean fullFlag) {
		super(context, fullFlag);
	}

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

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

	@Override
	public int getLayoutId() {
		return super.getLayoutId();
	}

	@Override
	protected void init(Context context) {
		super.init(context);
		soundPoolUtil= SoundPoolUtil.getInstance(context);
		mProgressBar = (SeekBar) findViewById(R.id.progress);


		mProgressBar.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View view, MotionEvent motionEvent) {
				if(isFinish){
					soundPoolUtil.playSoundWithRedId(R.raw.buyao);
					Toast toast = Toast.makeText(context,"触摸事件",Toast.LENGTH_SHORT);
					toast.setGravity(Gravity.TOP,0,0);
					toast.show();
					return true;
				}
				return false;
			}
		});
	}
}
