Send the tune only if ther is a change from the previous state
This commit is contained in:
parent
f11c15c0ce
commit
e4f72d05c3
1 changed files with 8 additions and 4 deletions
|
@ -23,6 +23,7 @@ class UpdateThread(threading.Thread):
|
|||
|
||||
def run(self, *args, **kwargs):
|
||||
self.alive = True
|
||||
current = None
|
||||
while self.alive:
|
||||
try:
|
||||
self.c.connect(host=self.plugin.config.get('host', 'localhost'), port=self.plugin.config.get('port', '6600'))
|
||||
|
@ -35,11 +36,14 @@ class UpdateThread(threading.Thread):
|
|||
status = self.c.status()
|
||||
if status['state'] == 'play' and self.alive:
|
||||
song = self.c.currentsong()
|
||||
self.xmpp.plugin['xep_0118'].publish_tune(artist=song.get('artist'),
|
||||
length=song.get('time'), title=song.get('title'),
|
||||
track=song.get('track'), block=False)
|
||||
else if status['state'] != 'play':
|
||||
if current != song:
|
||||
self.xmpp.plugin['xep_0118'].publish_tune(artist=song.get('artist'),
|
||||
length=song.get('time'), title=song.get('title'),
|
||||
track=song.get('track'), block=False)
|
||||
current = song
|
||||
elif status['state'] != 'play':
|
||||
self.xmpp.plugin['xep_0118'].stop(block=False)
|
||||
current = None
|
||||
self.c.disconnect()
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue