diff options
6 files changed, 121 insertions, 32 deletions
diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html index 64806e50d..5dc77f024 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html @@ -49,14 +49,20 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 <P> MovieCube Keys:<br> <ul> - <li> Cursor-Left - bwd 1s</li> - <li> Cursor-Up - fwd 10s</li> - <li> Cursor-Right - fwd 1s</li> - <li> Cursor-Down - bwd 10s</li> - <li> Escape - Restart w/ normal speed</li> - <li> Space - Toggle Pause</li> - <li> S - Half Speed</li> - <li> F - Double Speed</li> + <li> BWD / FWD: + <ul> + <li> 01s - Cursor left/right</li> + <li> 10s - Cursor down/up</li> + <li> 30s - Page down/up</li> + </ul></li> + <li> Speed: + <ul> + <li> Pause - Space bar</li> + <li> Half - Keypad minus</li> + <li> Double - Keypad plus</li> + <li> Reset - Keypad multiply</li> + </ul></li> + <li> Mute - M</li> </ul> </P> <P> diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube.html b/jnlp-files/jogl-applet-runner-newt-MovieCube.html index caaeba395..a154eb825 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube.html @@ -66,14 +66,20 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 <P> MovieCube Keys:<br> <ul> - <li> Cursor-Left - bwd 1s</li> - <li> Cursor-Up - fwd 10s</li> - <li> Cursor-Right - fwd 1s</li> - <li> Cursor-Down - bwd 10s</li> - <li> Escape - Restart w/ normal speed</li> - <li> Space - Toggle Pause</li> - <li> S - Half Speed</li> - <li> F - Double Speed</li> + <li> BWD / FWD: + <ul> + <li> 01s - Cursor left/right</li> + <li> 10s - Cursor down/up</li> + <li> 30s - Page down/up</li> + </ul></li> + <li> Speed: + <ul> + <li> Pause - Space bar</li> + <li> Half - Keypad minus</li> + <li> Double - Keypad plus</li> + <li> Reset - Keypad multiply</li> + </ul></li> + <li> Mute - M</li> </ul> </P> <P> diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index db73673a7..b5a9ce580 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -95,7 +95,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { anim.add(glWindowMain); glWindowMain.setVisible(true); - final MovieSimple demoMain = new MovieSimple(); + final MovieSimple demoMain = new MovieSimple(null); demoMain.setScaleOrig(true); final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); mPlayer.addEventListener( new GLMediaPlayer.GLMediaEventListener() { diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index f94390dcd..e54300de5 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -128,7 +128,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { anim.add(glWindowMain); glWindowMain.setVisible(true); - final MovieSimple demoMain = new MovieSimple(); + final MovieSimple demoMain = new MovieSimple(null); final GLMediaPlayer mPlayerMain = demoMain.getGLMediaPlayer(); if(mPlayerHUD) { demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); @@ -183,7 +183,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { demoHUD = new MovieSimple(mPlayerShared); mPlayerSub = mPlayerShared; } else { - demoHUD = new MovieSimple(); + demoHUD = new MovieSimple(null); mPlayerSub = demoHUD.getGLMediaPlayer(); } mPlayerSub.addEventListener( new GLMediaPlayer.GLMediaEventListener() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index d10bba8c7..fe11f6aca 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -81,10 +81,50 @@ public class MovieCube implements GLEventListener { defURI = _defURI; } + /** + * Default constructor which also issues {@link #initStream(URI, int, int, int)} w/ default values + * and polls until the {@link GLMediaPlayer} is {@link GLMediaPlayer.State#Initialized}. + * If {@link GLMediaEventListener#EVENT_CHANGE_EOS} is reached, the stream is started over again. + * <p> + * This default constructor is merely useful for some <i>drop-in</i> test, e.g. using an applet. + * </p> + */ public MovieCube() throws IOException, URISyntaxException { - this(-2.3f, 0f, 0f); + this(-2.3f, 0f, 0f); + + mPlayer.addEventListener(new GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCube State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + resetGLState(); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + // loop for-ever .. + mPlayer.seek(0); + mPlayer.play(); + } + } + }); + initStream(defURI, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 3 /* textureCount */); + StreamException se = null; + while( null == se && GLMediaPlayer.State.Initialized != mPlayer.getState() ) { + try { + Thread.sleep(16); + } catch (InterruptedException e) { } + se = mPlayer.getStreamException(); + } + if( null != se ) { + se.printStackTrace(); + throw new RuntimeException(se); + } } + /** Custom constructor, user needs to issue {@link #initStream(URI, int, int, int)} afterwards. */ public MovieCube(float zoom0, float rotx, float roty) throws IOException { this.zoom0 = zoom0; this.rotx = rotx; 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 907813191..d29381f35 100644 --- 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 @@ -95,7 +95,6 @@ public class MovieSimple implements GLEventListener { private int swapInterval = 1; private GLMediaPlayer mPlayer; - private boolean mPlayerExternal; private boolean mPlayerShared; private boolean mPlayerScaleOrig; private float[] verts = null; @@ -232,20 +231,58 @@ public class MovieSimple implements GLEventListener { } }; + /** + * Default constructor which also issues {@link #initStream(URI, int, int, int)} w/ default values + * and polls until the {@link GLMediaPlayer} is {@link GLMediaPlayer.State#Initialized}. + * If {@link GLMediaEventListener#EVENT_CHANGE_EOS} is reached, the stream is started over again. + * <p> + * This default constructor is merely useful for some <i>drop-in</i> test, e.g. using an applet. + * </p> + */ public MovieSimple() { - mPlayerScaleOrig = false; - mPlayerShared = false; - mPlayerExternal = false; - mPlayer = GLMediaPlayerFactory.createDefault(); - System.out.println("pC.1a "+mPlayer); + this(null); + + mPlayer.addEventListener(new GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCube State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + resetGLState(); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + // loop for-ever .. + mPlayer.seek(0); + mPlayer.play(); + } + } + }); + initStream(defURI, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 3 /* textureCount */); + StreamException se = null; + while( null == se && GLMediaPlayer.State.Initialized != mPlayer.getState() ) { + try { + Thread.sleep(16); + } catch (InterruptedException e) { } + se = mPlayer.getStreamException(); + } + if( null != se ) { + se.printStackTrace(); + throw new RuntimeException(se); + } } + /** Custom constructor, user needs to issue {@link #initStream(URI, int, int, int)} afterwards. */ public MovieSimple(GLMediaPlayer sharedMediaPlayer) throws IllegalStateException { - mPlayerScaleOrig = false; - mPlayerShared = true; - mPlayerExternal = true; mPlayer = sharedMediaPlayer; - System.out.println("pC.2 shared "+mPlayerShared+", "+mPlayer); + mPlayerScaleOrig = false; + mPlayerShared = null != mPlayer; + if( !mPlayerShared ) { + mPlayer = GLMediaPlayerFactory.createDefault(); + } + System.out.println("pC.1a shared "+mPlayerShared+", "+mPlayer); } public void initStream(URI streamLoc, int vid, int aid, int textureCount) { @@ -560,7 +597,7 @@ public class MovieSimple implements GLEventListener { System.out.println("pD.1 "+mPlayer+", disposePlayer "+disposePlayer); GL2ES2 gl = drawable.getGL().getGL2ES2(); if( disposePlayer ) { - if(!mPlayerExternal) { + if(!mPlayerShared) { mPlayer.destroy(gl); } System.out.println("pD.X "+mPlayer); @@ -717,7 +754,7 @@ public class MovieSimple implements GLEventListener { System.err.println("forceGLDef "+forceGLDef); System.err.println("swapInterval "+swapInterval); - final MovieSimple ms = new MovieSimple(); + final MovieSimple ms = new MovieSimple(null); ms.setSwapInterval(swapInterval); ms.setScaleOrig(!zoom); ms.setOrthoProjection(ortho); |