gpt4 book ai didi

Android GLSurfaceView over MediaPlayer-SurfaceView

转载 作者:行者123 更新时间:2023-11-29 00:38:53 28 4
gpt4 key购买 nike

我有一个 MediaPlayer 使用 SurfaceView 来显示视频。现在我想在 MediaPlayerto 上添加一个 GlSurfaceView 以在视频上呈现一个立方体。我正在使用相对布局。我可以分开完成这两项工作,但是我无法将 GlSurfaceView 放在 SurfaceView 上。它根本不呈现我用于立方体的 OpenGL 代码。有人可以帮忙吗?

   _cube = new CubeGLView(this);
_cube.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
_cube.setId(10002);
_cube.getHolder().setFormat(PixelFormat.TRANSLUCENT);
_cube.getHolder().setFormat(PixelFormat.RGBA_8888);
//_cube.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);

_render = new GlRenderer(_cube.getContext());
_cube.setRenderer(_render);
_cube.setVisibility(View.GONE);

RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);

mPreview.setLayoutParams(lp);
_cube.setLayoutParams(lp);

layout.addView(_cube);
layout.addView(mPreview);

setContentView(layout, rlp);

最佳答案

解决:mPreview = new SurfaceView(this); mPreview.setId(10001);

    mPreview.setOnClickListener(this);
mPreview.setClickable(true);

holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
extras = getIntent().getExtras();


_cube = new CubeGLView(this);
_cube.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

_cube.setId(10002);
_cube.getHolder().setFormat(PixelFormat.TRANSLUCENT);
_cube.getHolder().setFormat(PixelFormat.RGBA_8888);


_render = new GlRenderer(_cube.getContext());
_cube.setRenderer(_render);



RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);

mPreview.setLayoutParams(lp);

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(100,10, 0,0);
_cube.setLayoutParams(params);

DataManager datamanager = DataManager.getInstance();

if (!datamanager.isHasalreadyview()){
Log.d(TAG, "onCreate icicle == null");
layout.addView(_cube);
layout.addView(mPreview);
datamanager.setHasalreadyview(true);
}else{
Log.d(TAG, "onCreate icicle != null");
layout.addView(mPreview);
layout.addView(_cube);
}


setContentView(layout, rlp);

关于Android GLSurfaceView over MediaPlayer-SurfaceView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10855243/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com