def pause_all(): names=list_names('session') for name in names: if name.startswith(MPRIS_NAME): player=Player(name, sync_props=True) status=player.get_property('PlaybackStatus') if status=='Playing': player.Pause()
def get_active_player(listening=False): active=[] names=list_names('session') for name in names: if name.startswith(MPRIS_NAME): player=Player(name, receive_signals=listening, sync_props=True) status=player.get_property('PlaybackStatus') if status=='Playing': active.append(player) if len(active)> 1: log.warn('Have %d players active - dont know which to choose', len(active)) #TODO: Resolve when many player are running - have favorite one? return None elif len(active)==1: return active[0] else: return None