Пример #1
0
 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();
   }
 }
Пример #2
0
 private MenuItem menuItem(String title, Runnable r) {
   MenuItem mi = new MenuItem(title);
   mi.setOnAction(
       event -> {
         r.run();
       });
   return mi;
 }
Пример #3
0
 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();
   }
 }
Пример #4
0
 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();
   }
 }