diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/fourisland/fourpuzzle/Audio.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/com/fourisland/fourpuzzle/Audio.java b/src/com/fourisland/fourpuzzle/Audio.java index 3283c68..3f863e1 100755 --- a/src/com/fourisland/fourpuzzle/Audio.java +++ b/src/com/fourisland/fourpuzzle/Audio.java | |||
@@ -24,6 +24,7 @@ import javax.sound.sampled.Clip; | |||
24 | public class Audio { | 24 | public class Audio { |
25 | 25 | ||
26 | private static Sequencer seq; | 26 | private static Sequencer seq; |
27 | private static boolean firstInit = false; | ||
27 | 28 | ||
28 | public static void init() | 29 | public static void init() |
29 | { | 30 | { |
@@ -31,15 +32,20 @@ public class Audio { | |||
31 | seq = MidiSystem.getSequencer(); | 32 | seq = MidiSystem.getSequencer(); |
32 | seq.open(); | 33 | seq.open(); |
33 | 34 | ||
34 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { | 35 | if (!firstInit) |
35 | public void run() { | 36 | { |
36 | if (seq.isRunning()) { | 37 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { |
37 | seq.stop(); | 38 | public void run() { |
38 | } | 39 | if (seq.isRunning()) { |
40 | seq.stop(); | ||
41 | } | ||
39 | 42 | ||
40 | seq.close(); | 43 | seq.close(); |
41 | } | 44 | } |
42 | })); | 45 | })); |
46 | |||
47 | firstInit = true; | ||
48 | } | ||
43 | } catch (MidiUnavailableException ex) { | 49 | } catch (MidiUnavailableException ex) { |
44 | Logger.getLogger(Audio.class.getName()).log(Level.SEVERE, null, ex); | 50 | Logger.getLogger(Audio.class.getName()).log(Level.SEVERE, null, ex); |
45 | } | 51 | } |