Skip to content

Commit

Permalink
Track the NameOwnerChange signal and rename players internally accord…
Browse files Browse the repository at this point in the history
…ingly if the DBus service owner changes. Fixes #2.
  • Loading branch information
icasdri committed Dec 18, 2015
1 parent 443d0af commit 22ee4c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mpris2controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,22 @@ def handle_signal_properties_changed(self, interface, props, sig, sender=None):
self.markas_not_playing(sender)

def handle_signal_name_change(self, name, old_owner, new_owner):
del old_owner
if new_owner == "":
log.info("Received NameOwnerChange signal from bus daemon. Owner of %s lost.", name)
self.remove(name)
elif old_owner != "":
log.info("Received NameOwnerChange signal from bus daemon. %s is now %s.", old_owner, new_owner)
try:
player_index = self.not_playing.index(old_owner)
self.not_playing[player_index] = new_owner
except ValueError:
try:
self.playing.remove(old_owner)
self.playing.add(new_owner)
except ValueError:
# Then this isn't a player we're tracking, and it's not our concern
pass


def markas_playing(self, name):
# Add to playing
Expand Down

0 comments on commit 22ee4c5

Please sign in to comment.