title: Play music asynchronously over screens - Libgdx Java
body: <p>I want background music to be played over various screens of my game the music is initially started in the first screen class:</p>
  
  <pre><code>    boolean backgroundMusicPlaying = backgroundMusic.isPlaying();
  
      public MainMenuScreen(Game1 gam){
      (...)
      if(backgroundMusicPlaying != true){
                  backgroundMusic.play();
                  backgroundMusic.setVolume(0.3f);
                  backgroundMusic.setLooping(true);
                  backgroundMusicPlaying = true;
                  }
     (...)
   }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>The problem is when i return to this class after I have been to a previous screen in the game it restarts the music but i don't want this i want it to be a continuous loop.</p>
  
  <p>An example of how the screen's are changed to and from this class/screen:</p>
  
  <pre><code>game.setScreen(new playOptions(game));
  </code></pre>