libsaria: Play songs from outside the library
Pass in a file path and play! I even created a button as a notebook action widget. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
297f81213d
commit
78787d9cf5
|
@ -7,6 +7,8 @@ namespace libsaria
|
|||
{
|
||||
void init(string, bool, int, char **);
|
||||
void quit();
|
||||
|
||||
void play_outside_song(string &);
|
||||
}
|
||||
|
||||
#endif /* LIBSARIA_H */
|
||||
|
|
|
@ -36,6 +36,8 @@ namespace libsaria
|
|||
void read_tags();
|
||||
|
||||
public:
|
||||
Track();
|
||||
Track(string);
|
||||
Track(string, library::Path *);
|
||||
Track(ifstream &, library::Path *);
|
||||
~Track();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <libsaria/prefs.h>
|
||||
#include <libsaria/print.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/idle.h>
|
||||
#include <libsaria/fs.h>
|
||||
/*#include <libsaria/audio.h>
|
||||
|
@ -19,6 +20,8 @@
|
|||
#include <libsaria/stack.h>
|
||||
*/
|
||||
|
||||
static libsaria::Track outside_track;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
|
@ -51,4 +54,15 @@ namespace libsaria
|
|||
close_pipes();*/
|
||||
}
|
||||
|
||||
void play_outside_song(string &filepath)
|
||||
{
|
||||
try {
|
||||
outside_track = Track(filepath);
|
||||
} catch (string message) {
|
||||
println(message);
|
||||
return;
|
||||
}
|
||||
outside_track.play_now();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -74,6 +74,16 @@ namespace libsaria
|
|||
channels = prop->channels();
|
||||
}
|
||||
|
||||
Track::Track()
|
||||
{
|
||||
}
|
||||
|
||||
Track::Track(string file)
|
||||
{
|
||||
filepath = file;
|
||||
read_tags();
|
||||
}
|
||||
|
||||
Track::Track(string file, struct library::Path *lib_path)
|
||||
{
|
||||
filepath = file;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/libsaria.h>
|
||||
|
||||
static GtkWidget *tabs;
|
||||
static GtkWidget *action_box;
|
||||
static GtkWidget *open_button;
|
||||
|
@ -13,6 +15,7 @@ static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
|
|||
string file = ocarina::choose_file();
|
||||
if (file != "") {
|
||||
println("Playing file: " + file);
|
||||
libsaria::play_outside_song(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue