fix changing of song by storing playlist position for each track (fixes #1)
This commit is contained in:
parent
1bc7070231
commit
da06f1fff5
2 changed files with 16 additions and 4 deletions
14
mcg/mcg.py
14
mcg/mcg.py
|
@ -423,7 +423,7 @@ class Client(Base):
|
|||
song['time'] = 0
|
||||
if 'date' not in song:
|
||||
song['date'] = None
|
||||
track = MCGTrack(song['artist'], song['title'], song['track'], song['time'], song['date'], song['file'])
|
||||
track = MCGPlaylistTrack(song['artist'], song['title'], song['track'], song['time'], song['date'], song['file'], song['pos'])
|
||||
self._logger.debug("track: %r", track)
|
||||
# Album
|
||||
if 'album' not in song:
|
||||
|
@ -857,6 +857,18 @@ class MCGTrack:
|
|||
|
||||
|
||||
|
||||
class MCGPlaylistTrack(MCGTrack):
|
||||
def __init__(self, artists, title, track, length, date, file, pos):
|
||||
MCGTrack.__init__(self, artists, title, track, length, date, file)
|
||||
self._pos = int(pos)
|
||||
|
||||
|
||||
def get_pos(self):
|
||||
return self._pos
|
||||
|
||||
|
||||
|
||||
|
||||
class MCGConfig(configparser.ConfigParser):
|
||||
CONFIG_DIR = '~/.config/mcg/'
|
||||
|
||||
|
|
|
@ -828,10 +828,10 @@ class CoverPanel(Panel, Gtk.VBox):
|
|||
value = int(self._songs_scale.get_value())
|
||||
time = self._current_album.get_length()
|
||||
tracks = self._current_album.get_tracks()
|
||||
pos = len(tracks)
|
||||
for index in range(pos-1, -1, -1):
|
||||
pos = 0
|
||||
for index in range(len(tracks)-1, -1, -1):
|
||||
time = time - tracks[index].get_length()
|
||||
pos = pos - 1
|
||||
pos = tracks[index].get_pos()
|
||||
if time < value:
|
||||
break
|
||||
time = max(value - time - 1, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue