void stop(Runnable callback) { if (player != null) { new Tween(player.getVolume()) .tweenToZero( 0.06, 10L, (curVolume) -> { player.setVolume(curVolume); }, (zeroVolume) -> { isPlaying = false; try { if (currentAudioIn != null) { currentAudioIn.close(); } player.stop(); callback.run(); } catch (IOException | IllegalStateException | NullPointerException ex) { log.log(Level.ERROR, null, ex); } }); } else { callback.run(); } }
private MenuItem menuItem(String title, Runnable r) { MenuItem mi = new MenuItem(title); mi.setOnAction( event -> { r.run(); }); return mi; }
void pause(Runnable callback) { if (player != null) { new Tween(player.getVolume()) .tweenToZero( 0.06, 10L, (curVolume) -> { player.setVolume(curVolume); }, (zeroVolume) -> { player.pause(); callback.run(); }); isPlaying = false; } else { callback.run(); } }
void resume(Runnable callback) { if (player != null) { player.setVolume(0d); player.play(); new Tween(player.getVolume()) .tweenToValue( Settings.currentVolume, 0.06, 10L, (currentVolume) -> { player.setVolume(currentVolume); }, (valueVolume) -> { player.setVolume(valueVolume); callback.run(); }); isPlaying = true; } else { callback.run(); } }