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);
}
Aggregations