File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/com/redomar/game/audio Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public AudioHandler(String path, boolean music) {
3333
3434 private void check (String path ) {
3535 try {
36- if (!path .equals ( "" )) {
36+ if (!path .isEmpty ( )) {
3737 initiate (path );
3838 } else {
3939 throw new NullPointerException ();
@@ -89,14 +89,22 @@ public void setVolume(float velocity) throws NullPointerException {
8989 }
9090
9191 public void stop () {
92- if (clip .isRunning ()) clip .stop ();
93- if (music ) musicPrinter .print ("Stopping Music" );
94- active = false ;
92+ try {
93+ if (clip == null ) throw new RuntimeException ("Empty clip" );
94+ if (clip .isRunning ()) {
95+ clip .stop ();
96+ clip .close ();
97+ }
98+ } catch (Exception e ) {
99+ musicPrinter .print ("Audio Handler Clip not found" );
100+ } finally {
101+ if (music ) musicPrinter .print ("Stopping Music" );
102+ active = false ;
103+ }
95104 }
96105
97106 public void close () {
98107 stop ();
99- clip .close ();
100108 }
101109
102110 public boolean getActive () {
You can’t perform that action at this time.
0 commit comments