title: How to stop running clip
body: <p>I tried some topics there about it but music won't stop.
  My code is and looks fine, but probably I missing something?</p>
  <pre><code>public void playMusic(String musicLocation) {
          try {
              File musicPath = new File(musicLocation);
              AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicPath);
              Clip clip = AudioSystem.getClip();
              clip.open(audioInput);
              if (musicPath.exists()&amp;&amp;inGame == true) {
                  clip.start();
                  clip.loop(Clip.LOOP_CONTINUOUSLY);
              } 
              if (musicPath.exists()&amp;&amp;inGame == false) {
                  clip.stop();
              }
              else {
                  System.out.println(&quot;Cannot find audio file!&quot;);
                  
              }
          } catch (Exception ex) {
              ex.printStackTrace();
          }
      }
  </code></pre>
  <p>When games begin, and I click on start, <strong>inGame</strong> value is set up to true and music start playing. When round ends, value <strong>inGame</strong> is set up to false but my code above seems to not work. Code bellow makes clip start &quot;when I press 's' key&quot;</p>
  <pre><code>if (key == 's' || key == 'S') {
                  
                  inGame = true;
                  playMusic(filepath);
                  initGame();
  
              }
  </code></pre>
  <p>Thank you for ideas.
  edited: I forgot this <code>String filepath = &quot;pacmanMusic.wav&quot;;</code></p>
  <p>added due to question:</p>
  <pre><code>private void death() {
          pacsLeft--;
          
          if(pacsLeft == 0) {
              inGame = false;
              //createFile();
              
          }
          writeScoreToFile();     
          continueLevel();
      }
      
      private void win() {
          N_GHOSTS--;
          if(N_GHOSTS == 0) {
              inGame = false;
              win_intro++;
          }
          
          continueLevelWin();
      }
  </code></pre>