def _set_player(self):
players = []<EOL>for name, p in self._mpris_players.items():<EOL><INDENT>if "<STR_LIT>" not in p:<EOL><INDENT>if self.player_priority:<EOL><INDENT>try:<EOL><INDENT>priority = self.player_priority.index(p["<STR_LIT:name>"])<EOL><DEDENT>except ValueError:<EOL><INDENT>try:<EOL><INDENT>priority = self.player_priority.index("<STR_LIT:*>")<EOL><DEDENT>except ValueError:<EOL><INDENT>priority = None<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>priority = <NUM_LIT:0><EOL><DEDENT>if priority is not None:<EOL><INDENT>p["<STR_LIT>"] = priority<EOL><DEDENT><DEDENT>if p.get("<STR_LIT>") is not None:<EOL><INDENT>players.append((p["<STR_LIT>"], p["<STR_LIT>"], p["<STR_LIT:index>"], name))<EOL><DEDENT><DEDENT>if players:<EOL><INDENT>top_player = self._mpris_players.get(sorted(players)[<NUM_LIT:0>][<NUM_LIT:3>])<EOL><DEDENT>else:<EOL><INDENT>top_player = {}<EOL><DEDENT>self._player = top_player.get("<STR_LIT>")<EOL>self._player_details = top_player<EOL>self.py3.update()<EOL>
Sort the current players into priority order and set self._player
Players are ordered by working state then prefernce supplied by user
and finally by instance if a player has more than one running.