libsaria: Select songid using libsaria controls.cpp

I do this in the upper level namespace, rather than doing it in the
library, to make use of the play_filepath() function that I already have
written.
This commit is contained in:
Bryan Schumaker 2011-12-29 15:32:15 -05:00
parent c1cc33877c
commit 8049a7a9fd
2 changed files with 26 additions and 9 deletions

View File

@ -1,10 +1,13 @@
#ifndef LIBSARIA_CONTROLS_H
#define LIBSARIA_CONTROLS_H
#include <libsaria/track.h>
namespace libsaria
{
void next();
string next_file();
void play_id(sid_t &);
void set_pause_after(bool);
bool get_pause_after();
void toggle_play();

View File

@ -1,6 +1,7 @@
#include <libsaria/audio.h>
#include <libsaria/controls.h>
#include <libsaria/track.h>
#include <libsaria/library.h>
#include <libsaria/queue.h>
@ -9,6 +10,20 @@ static bool pause_after_current = false;
namespace libsaria
{
void play_file(string &filepath)
{
if (filepath == "")
return;
audio::load(filepath);
if (pause_after_current == true) {
audio::pause();
pause_after_current = false;
} else
audio::play();
}
string next_file()
{
if (queue::size() > 0)
@ -20,16 +35,15 @@ namespace libsaria
void next()
{
string filepath = next_file();
if (filepath != "")
libsaria::audio::load(filepath);
else
libsaria::audio::stop();
play_file(filepath);
}
if (pause_after_current == true) {
audio::pause();
pause_after_current = false;
} else
audio::play();
void play_id(sid_t &songid)
{
println("Playing id: %lu", songid);
string filepath = library::find_filepath(songid);
println(filepath);
play_file(filepath);
}
void set_pause_after(bool state)