package com.wasu.cs.widget.videoview;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.wasu.cs.utils.BitmapUtils;


/**
 * 播放器窗口
 * Created by jeepc on 16-11-09.
 */
public class PlayerWindow extends LinearLayout{

    private static final String TAG = "PlayerWindow";

    private boolean isFullScreen;



    private ImageView palyWinView;
    Context context;
    public PlayerWindow(Context context, LayoutParams layoutParms) {
        super(context);
        this.context = context;
        setFocusable(false);
        setFocusableInTouchMode(false);
        setBackgroundColor(Color.TRANSPARENT);

        init(context,layoutParms);
    }

    private void init(Context context,LayoutParams layoutParams) {
        this.setGravity(Gravity.CENTER);
        palyWinView = new ImageView(context);
        palyWinView.setLayoutParams(layoutParams);
        if (palyWinView.getParent() == null) {
            addView(palyWinView);
        }
    }

    public void setPalyWinViewBackgroundResource(int resId) {
        Bitmap bitmap = BitmapUtils.readBitMapByDecodeResourse(context,resId);
        palyWinView.setImageBitmap(bitmap);
    }




    public void handleFullScreen(boolean isFullScreen) {
        this.isFullScreen = isFullScreen;

        if (isFullScreen) {
            setVisibility(INVISIBLE);
        } else{
            setVisibility(VISIBLE);
        }
    }


}
