MD360Player4Android
介绍:
"2016被称为VR元年,所以今年伊始,我参考iOS上的HTY360PlayerIOS项目,做了一个Android上全景视频渲染的库,有点黑科技的感觉,说不定以后就用到了"
运行效果:
使用说明:
-
OpenGLES 2.0 required
-
Android 4.0.3 (IceCreamSandwich API-15) required
There are two way to use this library depend on your requirement,
根据你的需要,该库有两种使用方法。
使用MDGLSurfaceView
第一步 在layout xml中定义com.asha.vrlib.MDGLSurfaceView
...
<com.asha.vrlib.MDGLSurfaceView
android:id="@+id/md_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
第二步 当surface准备好了之后,把android.view.Surface设置到MediaPlayer上
public class MDGLSurfaceViewDemoActivity extends MediaPlayerActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_md_gl_surface);
MDGLSurfaceView mGLSurfaceView = (MDGLSurfaceView) findViewById(R.id.md_surface_view);
mGLSurfaceView.init(new MD360Renderer.IOnSurfaceReadyListener() {
@Override
public void onSurfaceReady(Surface surface) {
//MediaPlayer or something else.
getPlayer().setSurface(surface);
}
});
}
}
更灵活的方式: MD360Renderer
第一步 建立一个MD360Renderer并设置android.view.Surface。
public class MD360RenderDemoActivity extends MediaPlayerActivity {
private MD360Renderer mRenderer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_md_render);
mRenderer = MD360Renderer.with(this)
.listenSurfaceReady(new MD360Renderer.IOnSurfaceReadyListener() {
@Override
public void onSurfaceReady(Surface surface) {
getPlayer().setSurface(surface);
}
})
.build();
// init OpenGL
initOpenGL(R.id.surface_view);
}
}
第二步 自己初始化OpenGL,并把MD360Renderer设置到你的android.opengl.GLSurfaceView上。
private void initOpenGL(int glSurfaceViewResId) {
mGLSurfaceView = (GLSurfaceView) findViewById(glSurfaceViewResId);
if (GLUtil.supportsEs2(this)) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to our demo renderer, defined below.
mGLSurfaceView.setRenderer(mRenderer);
} else {
mGLSurfaceView.setVisibility(View.GONE);
Toast.makeText(MD360RenderDemoActivity.this, "OpenGLES2 not supported.", Toast.LENGTH_SHORT).show();
}
}
Reference
已下载
0