From 9e680fe86cd5b64aa758ce32666a6efa19118d3d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 3 Apr 2012 22:39:27 +0200 Subject: GLMediaPlayer/MovieSimple: Refine API (split setStream(GL, URL) -> initStream(URL) + initGL(GL)) .. IllegalStateException if wrong. Using internet streams of BigBuckBunny, if avail. - Splitting the initialization in stream and GL allows using the stream information (eg: size, ..) for setting the GLDrawable properties .. - Make the impl. more bullet proof .. --- .../com/jogamp/opengl/av/GLMediaPlayer.java | 42 ++++++++++++++-------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src/jogl/classes/com/jogamp') diff --git a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java index 0d07f69ac..95f7cc8b4 100644 --- a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.URL; import javax.media.opengl.GL; +import javax.media.opengl.GLException; import jogamp.opengl.Debug; @@ -12,17 +13,19 @@ import com.jogamp.opengl.util.texture.Texture; /** * Lifecycle of an GLMediaPlayer: * */ public interface GLMediaPlayer { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); public enum State { - Uninitialized(0), Stopped(1), Playing(2), Paused(3); + UninitializedStream(0), UninitializedGL(1), Stopped(2), Playing(3), Paused(4); public final int id; @@ -61,21 +64,32 @@ public interface GLMediaPlayer { public int[] getTextureWrapST(); /** - * Sets the stream to be used. Initializes all stream related states and GL resources. - * + * Sets the stream to be used. Initializes all stream related states. + *

+ * UninitializedStream -> UninitializedGL + *

+ * @throws IOException in case of difficulties to open or process the stream + * @throws IllegalStateException if not invoked in state UninitializedStream */ - public void setStream(GL gl, URL url) throws IOException; + public State initStream(URL url) throws IllegalStateException, IOException; + /** + * Initializes all GL related resources. + *

+ * UninitializedGL -> Stopped + *

+ * @throws GLException in case of difficulties to initialize the GL resources + * @throws IllegalStateException if not invoked in state UninitializedGL + */ + public State initGL(GL gl) throws IllegalStateException, GLException; + /** * Releases the GL and stream resources. *

* ANY -> Uninitialized *

*/ - public void destroy(GL gl); + public State destroy(GL gl); public void setPlaySpeed(float rate); @@ -107,6 +121,8 @@ public interface GLMediaPlayer { public long getCurrentPosition(); /** + * Allowed in state Stopped, Playing and Paused, otherwise ignored. + * * @param msec absolute desired time position in milliseconds * @return time current position in milliseconds, after seeking to the desired position **/ @@ -125,8 +141,6 @@ public interface GLMediaPlayer { */ public TextureFrame getNextTexture(); - public boolean isValid(); - public URL getURL(); /** -- cgit v1.2.3