libsaria: Fix deck::prev()
Having tracks add themselves to the recent playlist means that it also adds itself when going backwards through the playlist, resetting the cur iterator and causing the same 2 songs to be played. To get around this, I gave tracks a new load_unlisted() function to load without adding themselves to the recently played list. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
ce6782558d
commit
f5181c50b1
|
@ -47,6 +47,7 @@ namespace libsaria
|
|||
~Track();
|
||||
|
||||
void save(ofstream &);
|
||||
void load_unlisted(bool);
|
||||
void load(bool);
|
||||
void add_playlist(libsaria::Playlist *);
|
||||
void rm_playlist(libsaria::Playlist *);
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace libsaria
|
|||
{
|
||||
Track *track = recent_plist.next();
|
||||
if (track)
|
||||
track->load(true);
|
||||
track->load_unlisted(true);
|
||||
}
|
||||
|
||||
void set_on_new_playlist(void (*func)(Playlist *))
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
void Track::load(bool play)
|
||||
void Track::load_unlisted(bool play)
|
||||
{
|
||||
if (cur)
|
||||
cur->mark_played();
|
||||
|
@ -177,7 +177,6 @@ namespace libsaria
|
|||
audio::load(filepath, play);
|
||||
|
||||
if (path) {
|
||||
deck::list_recent(this);
|
||||
prefs::set("libsaria.current.library", path->id);
|
||||
prefs::set("libsaria.current.track", id);
|
||||
}
|
||||
|
@ -185,6 +184,13 @@ namespace libsaria
|
|||
cur = this;
|
||||
}
|
||||
|
||||
void Track::load(bool play)
|
||||
{
|
||||
load_unlisted(play);
|
||||
if (path)
|
||||
deck::list_recent(this);
|
||||
}
|
||||
|
||||
Track *current_track()
|
||||
{
|
||||
return cur;
|
||||
|
|
Loading…
Reference in New Issue