Callback for end of motion playback (Java)

[Last update: 10/06/2022]

Cubism SDK for Java is currently in alpha version, and the specifications may change in the beta or official version.



Cubism SDK for Java (alpha version) allows callback events to be retrieved at the end of motion playback.
In the sample, the callback function outputs log text to notify the end of playback.


Callback implementation

This time, because it processes by callback at the end of motion playback,
Framework/src/motion/ACubismMotion implements callback handling.

Java (alpha version) reproduces the callback mechanism using an object that implements the interface defined for callbacks.


Please note that in the sample, callbacks cannot be invoked in the following conditions.

  • When the motion being played is set as “looping”
  • When null is registered in the callback


Using Callback Functions

Implement what you actually want to be processed in the callback function.

The sample is implemented so that log text notifying the end of motion playback is output using the LAppPal.printLog method.
To change the processing at the end of motion playback, change the implementation of the following function.


The callback method is registered when the CubismUserMotion.loadMotion method is used in the Framework layer to load motion data, and the callback method is passed at the same time the motion is generated.
When there is already a motion, setFinishedMotionHandler() introduced in “Callback Implementation” is used.

In the sample, the callback function is passed from startRandomMotion(), which is called when onTap() is executed to obtain the tap event.
Since CubismMotion.doUpdateParameters() is actually playing back the motion, the implementation is made so that the callback function can be passed to CubismMotion.



On the development of implementation

The sample implements only the end of motion playback, but by developing these implementations, asynchronous processing can be used in callback functions after motion playback is finished, or
by reverse engineering the function from the actual process to which the callback is to be applied, callbacks can be implemented at points other than the end of motion playback.

© 2010 - 2022 Live2D Inc.