summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-13 06:49:31 +0100
committerSven Gothel <[email protected]>2023-03-13 06:49:31 +0100
commit6feb3738231210b03edefa7a60cf11e644fb7a5d (patch)
tree2871abe4dd85a5ccd69631cbedc1c195b5489031 /src
parent357964eba18e73eb69e0ad68c85fca0a0e1ea192 (diff)
GraphUI: MediaButton: Adapt GLMediaPlayer changes: Ready right away and reset on Init: GLMediaPlayer.initGL() + recreate GLRegion
Diffstat (limited to 'src')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java
index 241fad389..6fe3af1d5 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java
@@ -66,7 +66,6 @@ public class MediaButton extends TexSeqButton {
setPressedColorMod(1.1f, 1.1f, 1.1f, 0.7f);
setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f);
setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f);
- setEnabled(false); // data and shader n/a yet
}
public void setVerbose(final boolean v) { verbose = v; }
@@ -88,13 +87,12 @@ public class MediaButton extends TexSeqButton {
@Override
public void attributesChanged(final GLMediaPlayer mp, final int event_mask, final long when) {
- final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq;
if( verbose ) {
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_INIT & event_mask ) ) {
- MediaButton.this.setEnabled(true); // data and shader is available ..
+ resetGL = true;
}
if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) {
// FIXME: mPlayer.resetGLState();
@@ -104,11 +102,11 @@ public class MediaButton extends TexSeqButton {
@Override
public void run() {
// loop for-ever ..
- mPlayer.seek(0);
- mPlayer.resume();
+ mp.seek(0);
+ mp.resume();
} }.start();
} else if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) {
- final StreamException se = mPlayer.getStreamException();
+ final StreamException se = mp.getStreamException();
if( null != se ) {
se.printStackTrace();
}
@@ -121,15 +119,20 @@ public class MediaButton extends TexSeqButton {
((GLMediaPlayer)texSeq).destroy(gl);
}
+ volatile boolean resetGL = true;
+
@Override
public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) {
final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq;
- if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) {
+ if( resetGL ) {
+ resetGL = false;
try {
mPlayer.initGL(gl);
mPlayer.setAudioVolume( 0f );
- mPlayer.resume();
- markStateDirty();
+ region.destroy(gl);
+ region = null;
+ validate(gl, renderer);
+ markStateDirty(); // keep on going
} catch (final Exception e) {
e.printStackTrace();
}