It is a lite library to render 360 degree panorama video for Android.
MD360PlayerDemo.apk(21.7M, 360 demo video included)
- OpenGLES 2.0 required
- Android 4.0.3 (IceCreamSandwich API-15) required
Coming soon.
There are two way to use this library depend on your requirement,
STEP1 define com.asha.vrlib.MDGLSurfaceView
in the layout xml.
...
<com.asha.vrlib.MDGLSurfaceView
android:id="@+id/md_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
STEP2 attach the android.view.Surface
to your MediaPlayer or something else when the surface is ready.
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);
}
});
}
}
STEP1 build a MD360Renderer
and attach the 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);
}
}
STEP2 init OpenGL by yourself, and set the MD360Renderer
to your 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();
}
}
The MIT License (MIT)
Copyright (c) 2016 Asha