aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/android
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-03 22:39:27 +0200
committerSven Gothel <[email protected]>2012-04-03 22:39:27 +0200
commit9e680fe86cd5b64aa758ce32666a6efa19118d3d (patch)
treea7d8b78d6c4b05f3e0321133004bc5eb746258f7 /src/jogl/classes/jogamp/opengl/android
parent081404e20ac6055244408c6a4a7e7c2089183983 (diff)
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 ..
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/android')
-rw-r--r--src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java83
1 files changed, 43 insertions, 40 deletions
diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
index a2d9b9bf3..037ab779c 100644
--- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
+++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
@@ -54,13 +54,20 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
+ public float getPlaySpeed() {
+ return 0;
+ }
+
+ @Override
protected boolean startImpl() {
- try {
- mp.start();
- return true;
- } catch (IllegalStateException ise) {
- if(DEBUG) {
- ise.printStackTrace();
+ if(null != mp) {
+ try {
+ mp.start();
+ return true;
+ } catch (IllegalStateException ise) {
+ if(DEBUG) {
+ ise.printStackTrace();
+ }
}
}
return false;
@@ -68,12 +75,14 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
@Override
protected boolean pauseImpl() {
- try {
- mp.pause();
- return true;
- } catch (IllegalStateException ise) {
- if(DEBUG) {
- ise.printStackTrace();
+ if(null != mp) {
+ try {
+ mp.pause();
+ return true;
+ } catch (IllegalStateException ise) {
+ if(DEBUG) {
+ ise.printStackTrace();
+ }
}
}
return false;
@@ -81,21 +90,26 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
@Override
protected boolean stopImpl() {
- try {
- mp.stop();
- return true;
- } catch (IllegalStateException ise) {
- if(DEBUG) {
- ise.printStackTrace();
+ if(null != mp) {
+ try {
+ mp.stop();
+ return true;
+ } catch (IllegalStateException ise) {
+ if(DEBUG) {
+ ise.printStackTrace();
+ }
}
}
return false;
}
@Override
- public long seek(long msec) {
- mp.seekTo((int)msec);
- return mp.getCurrentPosition();
+ protected long seekImpl(long msec) {
+ if(null != mp) {
+ mp.seekTo((int)msec);
+ return mp.getCurrentPosition();
+ }
+ return 0;
}
@Override
@@ -105,7 +119,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
@Override
public TextureFrame getNextTexture() {
- if(null != atex) {
+ if(null != atex && null != mp) {
final boolean _updateSurface;
synchronized(updateSurfaceLock) {
_updateSurface = updateSurface;
@@ -127,11 +141,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
- public boolean isValid() {
- return null != mp;
- }
-
- @Override
protected void destroyImpl(GL gl) {
if(null != mp) {
mp.release();
@@ -140,7 +149,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
- protected void setStreamImplPreGL() throws IOException {
+ protected void initStreamImplPreGL() throws IOException {
if(null!=mp && null!=url) {
try {
final Uri uri = Uri.parse(url.toExternalForm());
@@ -152,7 +161,11 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
} catch (IllegalStateException e) {
throw new RuntimeException(e);
}
- mp.prepare();
+ try {
+ mp.prepare();
+ } catch (IOException ioe) {
+ throw new IOException("MediaPlayer failed to process stream <"+url.toExternalForm()+">: "+ioe.getMessage(), ioe);
+ }
width = mp.getVideoWidth();
height = mp.getVideoHeight();
@@ -166,11 +179,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
- protected void setStreamImplPostGL() throws IOException {
-
- }
-
- @Override
protected void destroyTexImage(GLContext ctx, TextureFrame imgTex) {
final AndroidTextureFrame atf = (AndroidTextureFrame) imgTex;
atf.getSurfaceTexture().release();
@@ -200,10 +208,5 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
AndroidGLMediaPlayerAPI14.this.newFrameAvailable(atex);
}
- };
-
- @Override
- public float getPlaySpeed() {
- return 0;
- }
+ };
}