Communicating Threads - Runnable - Application

This is my entrymessage:

java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call. 
Make sure you do not modify the scene from another thread!
Problem spatial name: Root Node

Yeah, for sure i may have touched the rootNode after updateGeometricState was called.

My question. I have to do this:

mp.setOnEndOfMedia(new Runnable() {
            @Override public void run() {
                initMediaPlayer(mediaView, actualList.getPath()+actualList.getMediaLocation());
                instance.detachChild(node);
                node = new TextureNode("mediaManagerTextureNode");
                node.init(app, mp);
                attachChild(node);
            }
        });

i know, if i wanted to do this i should use the simpleUpdate call, which is accessible everywhere, but how do i do it correct to not interfer with my update loop ?

Btw.: if this is solved i have a really nice candy to contribute, but without i cant’t be clear, that this is the only problem left ^^

How do i put that Runnable stuff somewhere threadsafe and still get my “endOfMedia” statement ?

My only concern is to get this thread safe. nothin more.

http://javadoc.jmonkeyengine.org/com/jme3/app/Application.html#enqueue(java.util.concurrent.Callable)

I know about that enqueue, but i am not capable to use it ! I cannot do anything here with my fantastic app.enqueue. Both types are void.

app.enqueue(
new Callable<Boolean>(){
 callMyMethod();
 return true;
});

my MediaPlayer, which is “javafx.scene.media.MediaPlayer”, takes a Runnable and is of type void, same as the app enqueue.
There’s no Callback.
The app.enqueue does the same thing. I can add a Runnable to the MediaPlayer and i can add a Callable to the app enqueue, but i cannot add them to both, so where is the solution ?
I need that Callable be used, when endOfMedia is reached, which i define by setting the runnable for “setOnEndOfMedia”.

This clue i didn’t get yet. I don’t need the definitions ^^ Btw.: Thx for contribution !

Sounds like a:

mp.setEndOfMedia(
new Runnable(){
  app.enqueue(new Callable<Boolean>(){
    //does something on the main thread..
  });
}
);
1 Like

So, here is the answer on how to wrap it !

    mp.setOnEndOfMedia(new Runnable() {
        @Override public void run() {
            app.enqueue(
            new Callable<Boolean>() {
                public Boolean call() throws Exception {
                    mp.stop();
                    initMediaPlayer(mediaView, actualList.getPath()+actualList.getMediaLocation());
                    detachChild(node);
                    node = new TextureNode("mediaManagerTextureNode");
                    node.init(app, mp);
                    attachChild(node);

                    return true;
                }
            });
        }
    });