aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/view/app/UserInterface.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index ed8e78f..e0121a2 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -105,6 +105,7 @@ abstract class UserInterface implements Viewable, ActionListener {
105 105
106 private final Timer timer; 106 private final Timer timer;
107 private TimerTask timerTask; 107 private TimerTask timerTask;
108 private boolean scenePlaying;
108 109
109 private OggClip audio; 110 private OggClip audio;
110 private boolean muted; 111 private boolean muted;
@@ -445,8 +446,10 @@ abstract class UserInterface implements Viewable, ActionListener {
445 * Skips the currently player Scene. 446 * Skips the currently player Scene.
446 */ 447 */
447 private void skipScene() { 448 private void skipScene() {
448 this.timerTask.run(); 449 if (this.scenePlaying) {
449 this.timerTask.cancel(); 450 this.timerTask.run();
451 this.timerTask.cancel();
452 }
450 } 453 }
451 454
452 /** 455 /**
@@ -484,14 +487,14 @@ abstract class UserInterface implements Viewable, ActionListener {
484 */ 487 */
485 private void playAudio(final String fileName) { 488 private void playAudio(final String fileName) {
486 if (this.audio != null) { 489 if (this.audio != null) {
487 this.audio.stop(); 490 // stop() and close() are not working properly...
488 this.audio.close(); 491 this.audio.pause();
489 } 492 }
490 493
491 try { 494 try {
492 this.audio = new OggClip(UserInterface.SOUND_DIR + fileName + UserInterface.SOUND_EXT); 495 this.audio = new OggClip(UserInterface.SOUND_DIR + fileName + UserInterface.SOUND_EXT);
493 this.setAudioGain();
494 this.audio.play(); 496 this.audio.play();
497 this.setAudioGain();
495 } catch (final IOException e) { 498 } catch (final IOException e) {
496 e.printStackTrace(); 499 e.printStackTrace();
497 } 500 }
@@ -508,7 +511,7 @@ abstract class UserInterface implements Viewable, ActionListener {
508 /** 511 /**
509 * Sets the gain. 512 * Sets the gain.
510 * 513 *
511 * FIXME: PulseAudio does not comply with the JSAPI 514 * PulseAudio does not comply with the JSAPI => pause/play instead of muting
512 */ 515 */
513 private void setAudioGain() { 516 private void setAudioGain() {
514 if (this.audio == null) { 517 if (this.audio == null) {
@@ -519,9 +522,11 @@ abstract class UserInterface implements Viewable, ActionListener {
519 } 522 }
520 523
521 if (this.muted) { 524 if (this.muted) {
522 this.audio.setGain(-1.0f); 525 // this.audio.setGain(0.0f);
523 } else { 526 this.audio.pause();
524 this.audio.setGain(1.0f); 527 } else if (this.audio.isPaused()) {
528 // this.audio.setGain(-1.0f);$
529 this.audio.resume();
525 } 530 }
526 } 531 }
527 532
@@ -611,10 +616,13 @@ abstract class UserInterface implements Viewable, ActionListener {
611 this.setIllustration(scene.name()); 616 this.setIllustration(scene.name());
612 this.playAudio(scene.name()); 617 this.playAudio(scene.name());
613 618
619 this.scenePlaying = true;
620
614 this.timerTask = new TimerTask() { 621 this.timerTask = new TimerTask() {
615 @Override 622 @Override
616 public void run() { 623 public void run() {
617 scene.getCallback().call(); 624 scene.getCallback().call();
625 UserInterface.this.scenePlaying = false;
618 } 626 }
619 }; 627 };
620 this.timer.schedule(this.timerTask, scene.getDuration()); 628 this.timer.schedule(this.timerTask, scene.getDuration());
@@ -623,8 +631,8 @@ abstract class UserInterface implements Viewable, ActionListener {
623 @Override 631 @Override
624 public void stopMusic() { 632 public void stopMusic() {
625 if (this.audio != null) { 633 if (this.audio != null) {
626 this.audio.stop(); 634 // stop() and close() are not working properly...
627 this.audio.close(); 635 this.audio.pause();
628 } 636 }
629 } 637 }
630 638