Skip to content

Latest commit

 

History

History
108 lines (89 loc) · 3.48 KB

README.md

File metadata and controls

108 lines (89 loc) · 3.48 KB

MD360Player4Android

It is a lite library to render 360 degree panorama video for Android.

Preview

ScreenShot

Demo APK

MD360PlayerDemo.apk(21.7M, 360 demo video included)

NOTICE

  • OpenGLES 2.0 required
  • Android 4.0.3 (IceCreamSandwich API-15) required

Gradle

Coming soon.

USAGE

There are two way to use this library depend on your requirement,

Using MDGLSurfaceView

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

More Flexible Way: MD360Renderer

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

Reference

LICENSE

The MIT License (MIT)

Copyright (c) 2016 Asha