use of gaiasky.event.IObserver in project gaiasky by langurmonkey.
the class EventScriptingInterface method runCameraPath.
@Override
public void runCameraPath(String file, boolean sync) {
em.post(Event.PLAY_CAMERA_CMD, this, file);
// Wait if needed
if (sync) {
Object monitor = new Object();
IObserver watcher = (event, source, data) -> {
switch(event) {
case CAMERA_PLAY_INFO:
Boolean status = (Boolean) data[0];
if (!status) {
synchronized (monitor) {
monitor.notify();
}
}
break;
default:
break;
}
};
em.subscribe(watcher, Event.CAMERA_PLAY_INFO);
// Wait for camera to finish
synchronized (monitor) {
try {
monitor.wait();
} catch (InterruptedException e) {
logger.error(e, "Error waiting for camera file to finish");
}
}
}
}
Aggregations