libsaria: Play tracks from the play_list
Rather than finding the id in the LibraryPath lists, I instead find it in the play_list list and store an iterator to this track.
This commit is contained in:
parent
b3cb20dd5d
commit
5ae5a349de
|
@ -41,15 +41,6 @@ namespace libsaria
|
|||
it->update();
|
||||
}
|
||||
|
||||
void library::play_id(ino_t &id)
|
||||
{
|
||||
list<LibraryPath>::iterator it;
|
||||
for (it = path_list.begin(); it != path_list.end(); it++) {
|
||||
if (it->play_id(id) == true)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool library::get_info(ino_t &id, void (*func)(Track &))
|
||||
{
|
||||
bool found = false;
|
||||
|
|
|
@ -2,9 +2,21 @@
|
|||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/print.h>
|
||||
#include "library.h"
|
||||
|
||||
static list<TrackTag> play_list;
|
||||
static list<TrackTag>::iterator cur_track = play_list.end();
|
||||
|
||||
static bool find_id(ino_t &inode, list<TrackTag>::iterator &it)
|
||||
{
|
||||
for (it = play_list.begin(); it != play_list.end(); it++) {
|
||||
if (it->get_inode() == inode)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
@ -14,6 +26,7 @@ namespace libsaria
|
|||
list<LibraryPath> *path_list = get_path_list();
|
||||
list<LibraryPath>::iterator it;
|
||||
list<TrackTag> *tag_list;
|
||||
list<TrackTag>::iterator i;
|
||||
|
||||
play_list.clear();
|
||||
|
||||
|
@ -21,7 +34,6 @@ namespace libsaria
|
|||
tag_list = it->get_list();
|
||||
play_list.insert(play_list.end(), tag_list->begin(), tag_list->end());
|
||||
}
|
||||
println("Rebuilding play list");
|
||||
}
|
||||
|
||||
void library::for_each(SourceModel *model)
|
||||
|
@ -33,6 +45,15 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
void library::play_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
if (find_id(id, it)) {
|
||||
cur_track = it;
|
||||
libsaria::audio::load(it->get_filepath());
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int library::size()
|
||||
{
|
||||
return play_list.size();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/library.h>
|
||||
#include "library.h"
|
||||
|
||||
|
@ -46,16 +45,6 @@ bool LibraryPath::get_info_id(ino_t &id, void (*func)(Track &))
|
|||
return false;
|
||||
}
|
||||
|
||||
bool LibraryPath::play_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
it = find_id(id);
|
||||
if (it == file_list.end())
|
||||
return false;
|
||||
libsaria::audio::load(it->get_filepath());
|
||||
return true;
|
||||
}
|
||||
|
||||
LibraryPath::LibraryPath(string dir)
|
||||
{
|
||||
path = dir;
|
||||
|
|
Loading…
Reference in New Issue