Calculate length even if song is in the middle

fixes #3
This commit is contained in:
boyska 2015-05-12 17:57:20 +02:00
parent 066377e589
commit be23532cda
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9

View file

@ -49,7 +49,9 @@ class Player(gevent.Greenlet):
def check_playlist(self): def check_playlist(self):
mpd_client = self._get_mpd() mpd_client = self._get_mpd()
songs = mpd_client.playlist() songs = mpd_client.playlist()
if(len(songs) >= self.min_playlist_length): current = mpd_client.currentsong()
pos = int(current.get('pos', 0)) + 1
if(len(songs) - pos >= self.min_playlist_length):
return return
self.log.info('need to add new songs') self.log.info('need to add new songs')
picker = gevent.Greenlet(audiogenerate, picker = gevent.Greenlet(audiogenerate,
@ -73,7 +75,7 @@ class Player(gevent.Greenlet):
# emitter = value['emitter'] # emitter = value['emitter']
kind = value['kind'] kind = value['kind']
args = value['args'] args = value['args']
if kind == 'timer' or (kind == 'mpc' and args[0] == 'playlist'): if kind == 'timer' or (kind == 'mpc' and args[0] in ('player', 'playlist')):
gevent.Greenlet.spawn(self.check_playlist) gevent.Greenlet.spawn(self.check_playlist)
elif kind == 'mpc': elif kind == 'mpc':
pass pass