Android Open Source - dttv-android Gl Video View






From Project

Back to project page dttv-android.

License

The source code is released under:

GNU General Public License

If you think the Android project dttv-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dttv.app.widget;
/*  w w w  . j  a v a  2  s . c o m*/
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.MotionEvent;


@SuppressLint("ClickableViewAccessibility")
public class GlVideoView extends GLSurfaceView{
  
  private float mPosX;
  private float mPosY;
  private float mCurrentPosX;
  private float mCurrentPosY;
  
  private OnTouchMoveListener moveListener;
  //Paint paint;
  
  public GlVideoView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setEGLContextClientVersion(2);
    // TODO Auto-generated constructor stub
    //paint = new Paint();
  }
  
  @Override
  public boolean onTrackballEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    return super.onTrackballEvent(event);
  }
  
  public void setTouchMoveListener(OnTouchMoveListener onTouchMoveListener){
    this.moveListener = onTouchMoveListener;
  }
  
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    switch(event.getAction()){
    case MotionEvent.ACTION_DOWN:
      moveListener.onTouch(event);
      mPosX = event.getX();
      mPosY = event.getY();
      break;
    case MotionEvent.ACTION_MOVE:
      mCurrentPosX = event.getX();
      mCurrentPosY = event.getY();
      if(mCurrentPosX-mPosX>10 && Math.abs(mCurrentPosY-mPosY)<100){
        //move right
      }else if(mCurrentPosX-mPosX<10 && Math.abs(mCurrentPosY-mPosY)<100){
        //move left
      }else if(mCurrentPosY-mPosY>10 && Math.abs(mCurrentPosX-mPosX)<100){
        //move down
        moveListener.onTouchMoveDown(mCurrentPosX);
      }else if(mCurrentPosY-mPosY<10 && Math.abs(mCurrentPosX-mPosX)<100){
        //move up
        moveListener.onTouchMoveUp(mCurrentPosX);
      }
      break;
    case MotionEvent.ACTION_UP:
      
      break;
    }
    return true;
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);
    /*if(paint==null)
      paint = new Paint();
    paint.setColor(Color.GRAY);
    
    RectF rectF = new RectF(0, 0, getWidth()/2, 100);
    canvas.drawRect(rectF, paint);
    paint.setColor(Color.BLUE);
    RectF rectF2 = new RectF(getWidth()/2, 0, getWidth(), getHeight());
    canvas.drawRect(rectF2, paint);
    canvas.drawLine(getWidth()/2, 0, getWidth()+2, getHeight(), paint);*/
  }
}




Java Source Code List

dttv.app.DtPlayer.java
dttv.app.FileBrowserActivity.java
dttv.app.FileShowActivity.java
dttv.app.IndexActivity.java
dttv.app.MainActivity.java
dttv.app.SettingActivity.java
dttv.app.VideoPlayerActivity.java
dttv.app.adapter.FileAdapter.java
dttv.app.compnent.Compnent.java
dttv.app.compnent.MethodPlayerCompnent.java
dttv.app.compnent.PopWindowCompnent.java
dttv.app.impl.ICallBack.java
dttv.app.impl.I_Async.java
dttv.app.impl.I_KeyIntercept.java
dttv.app.impl.I_OnMyKey.java
dttv.app.impl.I_PopWindow.java
dttv.app.model.Item.java
dttv.app.multithread.DataAsyncTask.java
dttv.app.utils.Constant.java
dttv.app.utils.ControlLightness.java
dttv.app.utils.FileUtil.java
dttv.app.utils.Log.java
dttv.app.utils.MultiMediaTypeUtil.java
dttv.app.utils.MusicUtils.java
dttv.app.utils.PlayerUtil.java
dttv.app.utils.SettingUtil.java
dttv.app.utils.TimesUtil.java
dttv.app.utils.VolumeUtil.java
dttv.app.view.SimpleDialog.java
dttv.app.widget.AudioUIFragment.java
dttv.app.widget.EffectWindow.java
dttv.app.widget.FilesUIFragment.java
dttv.app.widget.GlVideoView.java
dttv.app.widget.OnTouchMoveListener.java
dttv.app.widget.SlideTabsFragment.java
dttv.app.widget.VideoUIFragment.java