Skip to content

Commit 857902a

Browse files
committed
compatibility fix
When the system is not capable to play the sound, do not throw exception, just log it. For example on Linux there are several issues to play sound and there are no workarounds for that :(
1 parent ee3744c commit 857902a

File tree

1 file changed

+3
-1
lines changed
  • event-queue/src/main/java/com/iluwatar/event/queue

1 file changed

+3
-1
lines changed

event-queue/src/main/java/com/iluwatar/event/queue/Audio.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@ public static void update() {
132132
}
133133
Clip clip = null;
134134
try {
135+
headIndex++;
135136
clip = AudioSystem.getClip();
136137
clip.open(getPendingAudio()[headIndex].stream);
137138
clip.start();
138-
headIndex++;
139139
} catch (LineUnavailableException e) {
140140
System.err.println("Error occoured while loading the audio: The line is unavailable");
141141
e.printStackTrace();
142142
} catch (IOException e) {
143143
System.err.println("Input/Output error while loading the audio");
144144
e.printStackTrace();
145+
} catch (IllegalArgumentException e) {
146+
System.err.println("The system doesn't support the sound: " + e.getMessage());
145147
}
146148
}
147149

0 commit comments

Comments
 (0)