diff options
author | Sven Gothel <[email protected]> | 2012-04-04 06:15:05 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-04-04 06:15:05 +0200 |
commit | 74c6486a5eb40b760b500e836f4e4ffec8cb1ce5 (patch) | |
tree | 4aa64a004a551c805906b2ac3c85543f12f7bc25 /src/test | |
parent | 9e680fe86cd5b64aa758ce32666a6efa19118d3d (diff) |
Split Android MovieSimple Launcher to 3
00: One movie view, centered, no effects
01: Two movie views (Main + HUD) using same GLMediaPlayer [texture] and stream
02: Two movie views (Main + HUD) each using own GLMediaPlayer and stream
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java | 132 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00.java (renamed from src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java) | 7 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01.java | 80 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java | 80 | ||||
-rwxr-xr-x | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java | 93 |
5 files changed, 324 insertions, 68 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java index 8d8a80bad..d43c87efc 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java @@ -31,8 +31,11 @@ import java.io.IOException; import java.net.URLConnection; import java.util.Arrays; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; @@ -54,32 +57,45 @@ import android.util.Log; public class MovieSimpleActivity extends NewtBaseActivity { static String TAG = "NEWTGearsES2Activity"; - MouseAdapter demoMouseListener = new MouseAdapter() { + MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); if(src instanceof AndroidWindow) { - ((AndroidWindow)src).getAndroidView().bringToFront(); + ((AndroidWindow)src).requestFocus(false); } } }; @Override public void onCreate(Bundle savedInstanceState) { - Log.d(TAG, "onCreate - 0"); super.onCreate(savedInstanceState); - String[] urls = new String[] { + final boolean mPlayerLocal = Boolean.valueOf(System.getProperty("jnlp.mplayer.local")); + final boolean mPlayerNormal = Boolean.valueOf(System.getProperty("jnlp.mplayer.normal")); + final boolean mPlayerShared = !mPlayerNormal && Boolean.valueOf(System.getProperty("jnlp.mplayer.shared")); + Log.d(TAG, "onCreate - 0 - mPlayerLocal "+mPlayerLocal+", mPlayerNormal "+mPlayerNormal+", mPlayerShared "+mPlayerShared); + + String[] urls0 = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), - System.getProperty("jnlp.media0_url0") }; - final URLConnection ucH = getResource(urls, 0); - if(null == ucH) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls)); } - URLConnection ucL = null; // getResource(urls, 1); - if(null == ucL) { ucL = ucH; } + System.getProperty("jnlp.media0_url0") }; + final URLConnection urlConnection0 = getResource(urls0, mPlayerLocal ? 2 : 0); + if(null == urlConnection0) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls0)); } + + final URLConnection urlConnection1; + { + URLConnection _urlConnection1 = null; + if(!mPlayerShared && !mPlayerNormal) { + String[] urls1 = new String[] { System.getProperty("jnlp.media1_url0") }; + _urlConnection1 = getResource(urls1, 0); + } + if(null == _urlConnection1) { _urlConnection1 = urlConnection0; } + urlConnection1 = _urlConnection1; + } setTransparencyTheme(); setFullscreenFeature(getWindow(), true); - android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); getWindow().setContentView(viewGroup); // also initializes JOGL @@ -93,50 +109,80 @@ public class MovieSimpleActivity extends NewtBaseActivity { scrn.addReference(); try { - Animator animator = new Animator(); + final GLMediaPlayer mPlayerMain = GLMediaPlayerFactory.create(); + mPlayerMain.initStream(urlConnection0.getURL()); + + final GLMediaPlayer mPlayerHUD; + if(!mPlayerNormal) { + if(mPlayerShared) { + mPlayerHUD = mPlayerMain; + } else { + mPlayerHUD = GLMediaPlayerFactory.create(); + mPlayerHUD.initStream(urlConnection1.getURL()); + } + } else { + mPlayerHUD = null; + } + + final Animator animator = new Animator(); setAnimator(animator); - // Main - final MovieSimple demoMain = new MovieSimple(ucH.getURL()); - demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); - demoMain.setTransparency(0.9f); + // Main + final MovieSimple demoMain = new MovieSimple(mPlayerMain, false); + if(!mPlayerNormal) { + demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); + demoMain.setTransparency(0.9f); + } + demoMain.setScaleOrig(mPlayerNormal); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); - glWindowMain.addMouseListener(demoMouseListener); glWindowMain.setFullscreen(true); // setContentView(getWindow(), glWindowMain); - viewGroup.addView(((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView(), 0); + viewGroup.addView(((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView()); registerNEWTWindow(glWindowMain); glWindowMain.addGLEventListener(demoMain); animator.add(glWindowMain); glWindowMain.setVisible(true); - - final GLMediaPlayer demoMP = GLMediaPlayerFactory.create(); - demoMP.initStream(ucL.getURL()); - final MovieSimple demoHUD = new MovieSimple(demoMP); - final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD); - glWindowHUD.addMouseListener(demoMouseListener); - { - int x2 = scrn.getX(); - int y2 = scrn.getY(); - int w2 = scrn.getWidth()/2; - int h2 = scrn.getHeight()/2; - if(0 < demoMP.getWidth() && demoMP.getWidth()<w2) { - w2 = demoMP.getWidth(); - } - if(0 < demoMP.getHeight() && demoMP.getHeight()<h2) { - h2 = demoMP.getHeight(); + + if(null != mPlayerHUD) { + final MovieSimple demoHUD = new MovieSimple(mPlayerHUD, mPlayerShared); + final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD); + glWindowHUD.addMouseListener(toFrontMouseListener); + { + int x2 = scrn.getX(); + int y2 = scrn.getY(); + int w2 = scrn.getWidth()/2; + int h2 = scrn.getHeight()/2; + if(0 < mPlayerHUD.getWidth() && mPlayerHUD.getWidth()<w2) { + w2 = mPlayerHUD.getWidth(); + } + if(0 < mPlayerHUD.getHeight() && mPlayerHUD.getHeight()<h2) { + h2 = mPlayerHUD.getHeight(); + } + glWindowHUD.setPosition(x2, y2); + glWindowHUD.setSize(w2, h2); + System.err.println("HUD: "+mPlayerHUD); + System.err.println("HUD: "+w2+"x"+h2); } - glWindowHUD.setPosition(x2, y2); - glWindowHUD.setSize(w2, h2); - System.err.println("HUD: "+demoMP); - System.err.println("HUD: "+w2+"x"+h2); + // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); + viewGroup.addView(((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(), new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); + registerNEWTWindow(glWindowHUD); + glWindowHUD.addGLEventListener(demoHUD); + // Hand over shared ctx must happen while the shared GLWindow is + // guaranteed to be initialized. + glWindowMain.invoke(false, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + if(mPlayerShared) { + GLContext sharedCtx = glWindowMain.getContext(); + System.err.println("Shared: "+sharedCtx); + glWindowHUD.setSharedContext(sharedCtx); + } + animator.add(glWindowHUD); + glWindowHUD.setVisible(true); + glWindowHUD.requestFocus(false); + return true; + } } ); } - // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); - viewGroup.addView(((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(), 1, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); - registerNEWTWindow(glWindowHUD); - glWindowHUD.addGLEventListener(demoHUD); - animator.add(glWindowHUD); - glWindowHUD.setVisible(true); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00.java index 474e523e4..b95e5f883 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00.java @@ -32,7 +32,7 @@ import java.util.List; import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; -public class MovieSimpleActivityLauncher extends LauncherUtil.BaseActivityLauncher { +public class MovieSimpleActivityLauncher00 extends LauncherUtil.BaseActivityLauncher { static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity"; // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" }; @@ -40,10 +40,13 @@ public class MovieSimpleActivityLauncher extends LauncherUtil.BaseActivityLaunch @Override public void init() { - final OrderedProperties props = getProperties(); + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.mplayer.normal", "true"); + props.setProperty("jnlp.mplayer.shared", "false"); props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v"); props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); // props.setProperty("jogamp.debug.JNILibLoader", "true"); // props.setProperty("jogamp.debug.NativeLibrary", "true"); // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01.java new file mode 100644 index 000000000..28ac3b1a1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01.java @@ -0,0 +1,80 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class MovieSimpleActivityLauncher01 extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity"; + // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" }; + static String[] pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.mplayer.normal", "false"); + props.setProperty("jnlp.mplayer.shared", "true"); + props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v"); + props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("nativewindow.debug", "all"); + props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); + props.setProperty("jogl.debug.GLDrawable", "true"); + props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Window", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); + props.setProperty("jogamp.debug.IOUtil", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + @Override + public List<String> getPackages() { + return Arrays.asList(pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java new file mode 100644 index 000000000..ec7f8738f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java @@ -0,0 +1,80 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class MovieSimpleActivityLauncher02 extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity"; + // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" }; + static String[] pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.mplayer.normal", "false"); + props.setProperty("jnlp.mplayer.shared", "false"); + props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v"); + props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("nativewindow.debug", "all"); + props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); + props.setProperty("jogl.debug.GLDrawable", "true"); + props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Window", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); + props.setProperty("jogamp.debug.IOUtil", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + @Override + public List<String> getPackages() { + return Arrays.asList(pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 4c156b8f0..f2237484e 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -145,23 +145,32 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent GLMediaPlayer mPlayer; boolean mPlayerExternal; + boolean mPlayerShared; + boolean mPlayerScaleOrig; public MovieSimple(URL stream) throws IOException { + mPlayerScaleOrig = false; mPlayerExternal = false; mPlayer = GLMediaPlayerFactory.create(); mPlayer.addEventListener(this); - mPlayer.initStream(stream); + mPlayer.initStream(stream); System.out.println("p0.1 "+mPlayer); } - public MovieSimple(GLMediaPlayer mediaPlayer) throws IllegalStateException { - if(GLMediaPlayer.State.UninitializedGL != mediaPlayer.getState()) { + public MovieSimple(GLMediaPlayer mediaPlayer, boolean shared) throws IllegalStateException { + if(!shared && GLMediaPlayer.State.UninitializedGL != mediaPlayer.getState()) { throw new IllegalStateException("Given GLMediaPlayer not in state "+GLMediaPlayer.State.UninitializedGL+": "+mediaPlayer); } + mPlayerScaleOrig = false; + mPlayerShared = shared; mPlayerExternal = true; mPlayer = mediaPlayer; mPlayer.addEventListener(this); - System.out.println("p0.2 "+mPlayer); + System.out.println("p0.2 shared "+mPlayerShared+", "+mPlayer); + } + + public void setScaleOrig(boolean v) { + mPlayerScaleOrig = v; } private void run() { @@ -230,10 +239,14 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent boolean useExternalTexture = false; try { - mPlayer.initGL(gl); + if(!mPlayerShared) { + mPlayer.initGL(gl); + } System.out.println("p1 "+mPlayer); useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == mPlayer.getTextureTarget(); - mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } ); + if(!mPlayerShared) { + mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } ); + } } catch (GLException glex) { if(null != mPlayer) { mPlayer.destroy(gl); @@ -264,14 +277,23 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent } gl.glActiveTexture(GL.GL_TEXTURE0); - float aspect = 16.0f/9.0f; - float xs=1f, ys=1f; // scale object - float ss=1f, ts=1f; // scale tex-coord - - xs = aspect; // b > h - ys = 1f; // b > h - // ss = 1f/aspect; // b > h, crop width - // ts = 1f; // b > h + float dWidth = drawable.getWidth(); + float dHeight = drawable.getHeight(); + float mWidth = mPlayer.getWidth(); + float mHeight = mPlayer.getHeight(); + float aspect = mWidth/mHeight; + float xoff, yoff; + float xs, ys; // scale object + float ss, ts; // scale tex-coord + if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { + xoff = ((dWidth-mWidth)/2f)/dWidth; yoff = ((dHeight-mHeight)/2f)/dHeight; + xs = aspect * ( mWidth / dWidth ); ys = mHeight/dHeight; + ss = 1f; ts = 1f; + } else { + xoff = 0f; yoff = 0f; + xs = aspect; ys = 1f; // b>h + ss = 1f; ts = 1f; // b>h + } final GLArrayDataServer interleaved = GLArrayDataServer.createGLSLInterleaved(9, GL.GL_FLOAT, false, 12, GL.GL_STATIC_DRAW); { @@ -286,7 +308,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent FloatBuffer colorb = (FloatBuffer)colors.getBuffer(); // left-bottom - verticeb.put(-1f*xs); verticeb.put( -1f*ys); verticeb.put( 0); + verticeb.put(-1f*xs+xoff); verticeb.put( -1f*ys+yoff); verticeb.put( 0); texcoordb.put( tc.left() *ss); texcoordb.put( tc.bottom() *ts); if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) { colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha); @@ -295,7 +317,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent } // right-bottom - verticeb.put( 1f*xs); verticeb.put( -1f*ys); verticeb.put( 0); + verticeb.put( 1f*xs+xoff); verticeb.put( -1f*ys+yoff); verticeb.put( 0); texcoordb.put( tc.right() *ss); texcoordb.put( tc.bottom() *ts); if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) { colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha); @@ -304,7 +326,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent } // left-top - verticeb.put(-1f*xs); verticeb.put( 1f*ys); verticeb.put( 0); + verticeb.put(-1f*xs+xoff); verticeb.put( 1f*ys+yoff); verticeb.put( 0); texcoordb.put( tc.left() *ss); texcoordb.put( tc.top() *ts); if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) { colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha); @@ -313,7 +335,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent } // right-top - verticeb.put( 1f*xs); verticeb.put( 1f*ys); verticeb.put( 0); + verticeb.put( 1f*xs+xoff); verticeb.put( 1f*ys+yoff); verticeb.put( 0); texcoordb.put( tc.right() *ss); texcoordb.put( tc.top() *ts); if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) { colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha); @@ -333,12 +355,13 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent // Let's show the completed shader state .. System.out.println(st); - startTime = System.currentTimeMillis(); - if(null!=mPlayer) { + start(); System.out.println("p1 "+mPlayer); - mPlayer.start(); } + + startTime = System.currentTimeMillis(); + if (drawable instanceof Window) { Window window = (Window) drawable; window.addMouseListener(this); @@ -346,7 +369,21 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent winHeight = window.getHeight(); } } + + public void start() { + if(null!=mPlayer) { + mPlayer.start(); + System.out.println("pStart "+mPlayer); + } + } + public void stop() { + if(null!=mPlayer) { + mPlayer.stop(); + System.out.println("pStop "+mPlayer); + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { if(null == mPlayer) { return; } winWidth = width; @@ -375,9 +412,14 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent public void dispose(GLAutoDrawable drawable) { if(null == mPlayer) { return; } + stop(); + GL2ES2 gl = drawable.getGL().getGL2ES2(); - mPlayer.destroy(gl); + mPlayer.removeEventListener(this); + if(!mPlayerExternal) { + mPlayer.destroy(gl); + } mPlayer=null; pmvMatrixUniform = null; pmvMatrix.destroy(); @@ -415,7 +457,12 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent Texture tex = null; if(null!=mPlayer) { - final GLMediaPlayer.TextureFrame texFrame=mPlayer.getNextTexture(); + final GLMediaPlayer.TextureFrame texFrame; + if(mPlayerShared) { + texFrame=mPlayer.getLastTexture(); + } else { + texFrame=mPlayer.getNextTexture(); + } tex = texFrame.getTexture(); tex.enable(gl); tex.bind(gl); |