title: Pygame Playlist Continuous in the Background
body: <p>I'm trying to get background music for my game, but I can't seem to figure it out perfectly. I've used pygame in the past, but it was only for one song during the credits of my game. 
  I want the playlist to play continuously picking each track randomly. I've managed to get this working in a separate test file. I will post this code down below.</p>
  
  <p>The problem is when I call this function in my main game, the music plays the first track, and then stops. If I put in </p>
  
  <pre><code>while pygame.mixer.music.get_busy():
      continue
  </code></pre>
  
  <p>It just plays the music and doesn't let me play the game. I want it to loop continuously through the playlist while the user plays the game (it's a text based game so it uses <code>raw_input()</code> a lot.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import pygame
  import random
  
  pygame.mixer.init()
  
  _songs = [songs, are, here]
  
  _currently_playing_song = None
  
  def music():
      global _currently_playing_song, _songs
      next_song = random.choice(_songs)
      while next_song == _currently_playing_song:
          next_song = random.choice(_songs)
      _currently_playing_song = next_song
      pygame.mixer.music.load(next_song)
      pygame.mixer.music.play()
  
  while True: ## This part works for the test, but will not meet my needs
      music() ## for the full game.
      while pygame.mixer.music.get_busy():
          continue
  </code></pre>
  
  <p>(P.S. I learned python through Zed Shaw's "Learn Python The Hard Way" so my game structure uses the Engine and Map system from the book)</p>