From 857902ab95f4c4137fb93976c9c664820e7b27af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Kuprivecz?= Date: Thu, 11 May 2017 21:41:25 +0200 Subject: [PATCH] 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 :( --- event-queue/src/main/java/com/iluwatar/event/queue/Audio.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java index b482acca1..7c2f04d09 100644 --- a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java +++ b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java @@ -132,16 +132,18 @@ public class Audio { } Clip clip = null; try { + headIndex++; clip = AudioSystem.getClip(); clip.open(getPendingAudio()[headIndex].stream); clip.start(); - headIndex++; } catch (LineUnavailableException e) { System.err.println("Error occoured while loading the audio: The line is unavailable"); e.printStackTrace(); } catch (IOException e) { System.err.println("Input/Output error while loading the audio"); e.printStackTrace(); + } catch (IllegalArgumentException e) { + System.err.println("The system doesn't support the sound: " + e.getMessage()); } }