title: How to code to play MP3?
body: <p>I was making a few lines of code which alternatively prints out "tick"s and "tock"s every 0.5 second, and prints out "done!" after 60 seconds. </p>
  
  <pre><code>import javax.sound.sampled.*;
  
  public class Thread0001 {
      public static void main(String args[]) {
          for(int i=0; i&lt;60; i++) {
              try {
                  Thread.sleep(500);
                  if(i%2 == 0) {
                      System.out.print("tick ");
                      try {
                          AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(Thread0001.class.getClass().getResource
                                  ("Users/Marshall/Documents/Sources/Elevator.mp3"));
                          Clip clip = AudioSystem.getClip();
                          clip.open(audioInputStream);
                          clip.start();
                      } catch(Exception e) {
  
                      }
                  }
                  else
                      System.out.print("tock ");
                  if(i == 59) { // when it reaches 60 seconds
                      System.out.println("done!");
                  }
              } catch(Exception e) {
  
              }
          }
      }
  }
  </code></pre>
  
  <p>Well, everything seemed fine but one thing - I also put a code to emit an elevator bell sound every "tick". This code does not seem to be working, so can somebody help me out with this issue?</p>