libsaria: Track the length of playlists
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
026b17a6a5
commit
e0ebe4c97f
|
@ -33,6 +33,7 @@ namespace libsaria
|
|||
class Playlist {
|
||||
private:
|
||||
unsigned int flags;
|
||||
unsigned int length;
|
||||
PlaylistType type;
|
||||
list<Track *>::iterator cur;
|
||||
|
||||
|
@ -65,6 +66,7 @@ namespace libsaria
|
|||
string &get_name();
|
||||
void rename(string &);
|
||||
unsigned int get_size();
|
||||
unsigned int get_length();
|
||||
PlaylistType get_type();
|
||||
|
||||
virtual void add_tracks(list<Track *> &) = 0;
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace libsaria
|
|||
string &get_comment();
|
||||
string &get_genre();
|
||||
string &get_lenstr();
|
||||
int &get_length();
|
||||
unsigned int &get_year();
|
||||
unsigned int &get_track();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace libsaria
|
|||
it = tracks.begin();
|
||||
for (cur_it = plist.begin(); cur_it != plist.end(); cur_it++) {
|
||||
if ((*cur_it) == (*it)) {
|
||||
length += (*it)->get_length();
|
||||
RENDER( insert(*it, ins_index) );
|
||||
if (it++ == tracks.end())
|
||||
break;
|
||||
|
@ -51,6 +52,7 @@ namespace libsaria
|
|||
|
||||
for (it = tracks.begin(); it != tracks.end(); it++) {
|
||||
plist.push_back(*it);
|
||||
length += (*it)->get_length();
|
||||
RENDER( insert(*it, plist.size()) );
|
||||
};
|
||||
|
||||
|
@ -68,6 +70,7 @@ namespace libsaria
|
|||
tracks.reverse();
|
||||
for (it = tracks.begin(); it != tracks.end(); it++) {
|
||||
plist.push_front(*it);
|
||||
length += (*it)->get_length();
|
||||
RENDER( insert(*it, 0) );
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace libsaria
|
|||
return res;
|
||||
}
|
||||
|
||||
length -= (*cur)->get_length();
|
||||
cur = plist.erase(cur);
|
||||
if (cur == plist.end())
|
||||
cur = plist.begin();
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace libsaria
|
|||
name = n;
|
||||
flags = f;
|
||||
type = t;
|
||||
length = 0;
|
||||
renderer = NULL;
|
||||
cur = plist.begin();
|
||||
}
|
||||
|
@ -56,6 +57,11 @@ namespace libsaria
|
|||
return plist.size();
|
||||
}
|
||||
|
||||
unsigned int Playlist::get_length()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
PlaylistType Playlist::get_type()
|
||||
{
|
||||
return type;
|
||||
|
|
|
@ -39,6 +39,11 @@ namespace libsaria
|
|||
return lenstr;
|
||||
}
|
||||
|
||||
int &Track::get_length()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
unsigned int &Track::get_year()
|
||||
{
|
||||
return year;
|
||||
|
|
Loading…
Reference in New Issue