libsaria: Track play count
I've had a library field for this for a while, but I haven't been using it. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
36bd2c2b66
commit
34cd70fa39
|
@ -41,6 +41,7 @@ namespace libsaria
|
|||
gint64 position();
|
||||
string posstr();
|
||||
string durstr();
|
||||
bool played();
|
||||
|
||||
/* Volume functions */
|
||||
/*float get_volume();
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace libsaria
|
|||
void add_path(string);
|
||||
void delete_path(Path *);
|
||||
void update_path(Path *);
|
||||
void save_path(Path *);
|
||||
Track *lookup(unsigned int, unsigned int);
|
||||
Playlist *get_playlist();
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace libsaria
|
|||
string *artist_lc;
|
||||
string *album_lc;
|
||||
void read_tags();
|
||||
void mark_played();
|
||||
|
||||
public:
|
||||
Track();
|
||||
|
|
|
@ -99,4 +99,9 @@ namespace libsaria
|
|||
return to_string(position());
|
||||
}
|
||||
|
||||
bool audio::played()
|
||||
{
|
||||
return position() > ((duration() * 3) / 4);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ static void do_save_path(ofstream &stream, void *data)
|
|||
(*it).save(stream);
|
||||
}
|
||||
|
||||
void save_path(libsaria::library::Path *path)
|
||||
void libsaria::library::save_path(libsaria::library::Path *path)
|
||||
{
|
||||
string filepath = libdir + "/" + id_to_filename(path->id);
|
||||
libsaria::app::save(filepath, do_save_path, &path->data_state, path);
|
||||
|
|
|
@ -8,7 +8,6 @@ extern libsaria::Set lib_playlist;
|
|||
|
||||
void do_update_path(struct libsaria::library::Path *);
|
||||
void notify_path_updated(struct libsaria::library::Path *);
|
||||
void save_path(struct libsaria::library::Path *);
|
||||
libsaria::library::Path *push_path(libsaria::library::Path &);
|
||||
unsigned int schedule_load();
|
||||
void remove_file(libsaria::library::Path *);
|
||||
|
|
|
@ -143,9 +143,22 @@ namespace libsaria
|
|||
{
|
||||
}
|
||||
|
||||
void Track::mark_played()
|
||||
{
|
||||
if (audio::played()) {
|
||||
count++;
|
||||
path->data_state = DIRTY;
|
||||
libsaria::library::save_path(path);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::load(bool play)
|
||||
{
|
||||
if (cur)
|
||||
cur->mark_played();
|
||||
|
||||
println("Loading: " + title + " by " + artist);
|
||||
|
||||
if (path) {
|
||||
prefs::set("libsaria.current.library", path->id);
|
||||
prefs::set("libsaria.current.track", id);
|
||||
|
|
Loading…
Reference in New Issue