Search in sources :

Example 1 with GSYTextureView

use of com.shuyu.gsyvideoplayer.GSYTextureView in project GSYVideoPlayer by CarGuo.

the class CustomGSYVideoPlayer method addTextureView.

@Override
protected void addTextureView() {
    super.addTextureView();
    if (mPreviewLayout.getChildCount() > 0) {
        mPreviewLayout.removeAllViews();
    }
    mPreviewTexture = null;
    mPreviewTexture = new GSYTextureView(getContext());
    mPreviewTexture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {

        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            GSYPreViewManager.instance().setDisplay(new Surface(surface));
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
            GSYPreViewManager.instance().setDisplay(null);
            return true;
        }

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surface) {
        }
    });
    mPreviewTexture.setRotation(mRotate);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mPreviewLayout.addView(mPreviewTexture, layoutParams);
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) RelativeLayout(android.widget.RelativeLayout) GSYTextureView(com.shuyu.gsyvideoplayer.GSYTextureView) GSYTextureView(com.shuyu.gsyvideoplayer.GSYTextureView) TextureView(android.view.TextureView) Surface(android.view.Surface)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)1 Surface (android.view.Surface)1 TextureView (android.view.TextureView)1 RelativeLayout (android.widget.RelativeLayout)1 GSYTextureView (com.shuyu.gsyvideoplayer.GSYTextureView)1