1
0

Fix sound playing

This commit is contained in:
Victor 2014-03-25 11:27:34 +02:00
parent b972169341
commit 1727579f84

View File

@ -34,7 +34,7 @@ public enum Sound {
} }
public void play() { public void play() {
if (enabled) { if (enabled && (soundClip != null)) {
soundClip.setFramePosition(0); soundClip.setFramePosition(0);
soundClip.start(); soundClip.start();
} }
@ -48,6 +48,9 @@ public enum Sound {
clip = AudioSystem.getClip(); clip = AudioSystem.getClip();
clip.open(ais); clip.open(ais);
} }
} catch (IllegalArgumentException iae) {
Sound.setEnabled(false);
ExceptionHandler.handle(iae);
} catch (IOException | UnsupportedAudioFileException | LineUnavailableException ex) { } catch (IOException | UnsupportedAudioFileException | LineUnavailableException ex) {
ExceptionHandler.handle(ex); ExceptionHandler.handle(ex);
} }