parameters: (self)
docstring: Main loop: 
          - monitors state of all players
          - pauses players if a new player starts palyback
docstring_summary: Main loop: 
          - monitors state of all players
          - pauses players if a new player starts palyback
docstring_tokens: Main loop : - monitors state of all players - pauses players if a new player starts palyback
function: def main_loop(self):
          """ 
          Main loop: 
          - monitors state of all players
          - pauses players if a new player starts palyback
          """
  
          finished = False
          md = Metadata()
          active_players = set()
          while not(finished):
              new_player_started = None
  
              for p in self.retrievePlayers():
  
                  if p not in self.state_table:
                      self.state_table[p] = PlayerState()
  
                  try:
                      state = self.retrieveState(p).lower()
                  except:
                      logging.info("Got no state from " + p)
                      state = "unknown"
                  self.state_table[p].state = state
  
                  # Check if playback started on a player that wasn't
                  # playing before
                  if state == PLAYING:
                      if (p not in active_players):
                          new_player_started = p
                          active_players.add(p)
  
                      md_old = self.state_table[p].metadata
                      md = self.retrieveMeta(p)
  
                      self.state_table[p].metadata = md
                      if md is not None:
                          if not(md.sameSong(md_old)):
                              self.metadata_notify(md)
                  else:
                      if p in active_players:
                          active_players.remove(p)
  
              if new_player_started is not None:
                  if self.auto_pause:
                      logging.info(
                          "new player started, pausing other active players")
                      self.pause_inactive(new_player_started)
                  else:
                      logging.debug("auto-pause disabled")
  
              time.sleep(0.2)
function_tokens: def main_loop ( self ) : finished = False md = Metadata ( ) active_players = set ( ) while not ( finished ) : new_player_started = None for p in self . retrievePlayers ( ) : if p not in self . state_table : self . state_table [ p ] = PlayerState ( ) try : state = self . retrieveState ( p ) . lower ( ) except : logging . info ( "Got no state from " + p ) state = "unknown" self . state_table [ p ] . state = state # Check if playback started on a player that wasn't # playing before if state == PLAYING : if ( p not in active_players ) : new_player_started = p active_players . add ( p ) md_old = self . state_table [ p ] . metadata md = self . retrieveMeta ( p ) self . state_table [ p ] . metadata = md if md is not None : if not ( md . sameSong ( md_old ) ) : self . metadata_notify ( md ) else : if p in active_players : active_players . remove ( p ) if new_player_started is not None : if self . auto_pause : logging . info ( "new player started, pausing other active players" ) self . pause_inactive ( new_player_started ) else : logging . debug ( "auto-pause disabled" ) time . sleep ( 0.2 )