title: Looping Background Music in Java?
body: <p>I am trying to get music to play in my application and I have this code but I just get a null pointer exception. The file is in the correct directory so I don't know where I'm slipping up.</p>
  
  <pre><code>public void startBGMusic(){
      AudioPlayer myBackgroundPlayer = AudioPlayer.player;
      ContinuousAudioDataStream myLoop = null;
      try {
            AudioStream myBackgroundMusic = new AudioStream(new FileInputStream(new File(getClass().getResource("Act/Music/OverTheInferno.wav").toURI())));
            AudioData myData = myBackgroundMusic.getData();
            myLoop = new ContinuousAudioDataStream(myData);
      }catch(Exception error){
          System.out.println("File Not Found");
          System.out.println(error);
      }
      myBackgroundPlayer.start(myLoop);  
  }
  </code></pre>