libsaria: Pause after current song

What if you want to leave and a good song starts playing?  This solves
the problem by loading the next song, but not playing it so the user can
go away and listen to it when they come back.
This commit is contained in:
Bryan Schumaker 2011-12-11 21:03:09 -05:00
parent 304b581274
commit 5c6d7903a8
4 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,8 @@
namespace libsaria
{
void next();
void set_pause_after(bool);
bool get_pause_after();
};
#endif /* LIBSARIA_CONTROLS_H */

View File

@ -60,7 +60,6 @@ namespace libsaria
cur_file = file;
g_object_set(G_OBJECT(get_player()), "uri", uri.c_str(), NULL);
trigger_callback(TRACK_LOADED);
play();
}
string audio::get_current_file()

View File

@ -1,8 +1,11 @@
#include <libsaria/audio.h>
#include <libsaria/controls.h>
#include <libsaria/library.h>
#include <libsaria/queue.h>
static bool pause_after_current = false;
namespace libsaria
{
@ -12,6 +15,22 @@ namespace libsaria
queue::next();
else
library::next();
if (pause_after_current == true) {
audio::pause();
pause_after_current = false;
} else
audio::play();
}
void set_pause_after(bool state)
{
pause_after_current = state;
}
bool get_pause_after()
{
return pause_after_current;
}
}; /* Namespace: libsaria */

View File

@ -153,6 +153,7 @@ namespace libsaria
if (find_id(id, it)) {
cur_track = it;
libsaria::audio::load((*it)->get_filepath());
libsaria::audio::play();
}
}