aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-24 03:26:02 +0200
committerSven Gothel <[email protected]>2023-09-24 03:26:02 +0200
commitff36502e7ffeb9108368c517c401fad120b73d0a (patch)
tree9fbc0e08647649931ec67b52ee72aa485cc713ea /src/demos/com/jogamp/opengl
parentf29347ff72a13fa8344d21dc3589af3ff8b370cf (diff)
UISceneDemo20 Use onToggle(..) for media-button (audio on/off) as well as use direct lambdas for all its other listener
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index b9e455ec3..a66531a68 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -710,13 +710,9 @@ public class UISceneDemo20 implements GLEventListener {
final ALAudioSink[] alAudioSink = { null };
- button.addMouseListener(new Shape.MouseGestureAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- final Shape.EventInfo info = (Shape.EventInfo)e.getAttachment();
- final MediaButton s = (MediaButton)info.shape;
- mPlayer.setAudioVolume( s.isToggleOn() ? 1f : 0f );
- } } );
+ button.onToggle( (final Shape s) -> {
+ mPlayer.setAudioVolume( s.isToggleOn() ? 1f : 0f );
+ });
mPlayer.addEventListener( new GLMediaEventListener() {
@Override
public void newFrameAvailable(final GLMediaPlayer ts, final TextureFrame newFrame, final long when) {
@@ -740,30 +736,22 @@ public class UISceneDemo20 implements GLEventListener {
}
});
- final Shape.Listener setAudioPosition = new Shape.Listener() {
- @Override
- public void run(final Shape shape) {
- final ALAudioSink aSink = alAudioSink[0];
- if( null != aSink ) {
- setSoundPosition(shape, aSink.getContext(), aSink.getSource());
- }
+ button.onMove( (final Shape shape) -> {
+ final ALAudioSink aSink = alAudioSink[0];
+ if( null != aSink ) {
+ setSoundPosition(shape, aSink.getContext(), aSink.getSource());
}
- };
- final Shape.ListenerBool initAudio = new Shape.ListenerBool() {
- @Override
- public boolean run(final Shape shape) {
- final ALAudioSink aSink = alAudioSink[0];
- if( null != aSink ) {
- initSound(shape, aSink.getContext(), aSink.getSource());
- System.err.println("Media Audio: "+aSink);
- return true;
- } else {
- return false;
- }
+ });
+ button.onInit( (final Shape shape) -> {
+ final ALAudioSink aSink = alAudioSink[0];
+ if( null != aSink ) {
+ initSound(shape, aSink.getContext(), aSink.getSource());
+ System.err.println("Media Audio: "+aSink);
+ return true;
+ } else {
+ return false;
}
- };
- button.onInit( initAudio );
- button.onMove( setAudioPosition );
+ });
buttonsRight.addShape(button);
mPlayer.playStream(filmURL, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT);