libsaria: Play a track using Track::play_now()
It loads and begins playback. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
5163447638
commit
f1bbbbcc5c
|
@ -25,10 +25,10 @@ namespace libsaria
|
|||
void set_device(string &);*/
|
||||
|
||||
/* Playback control functions */
|
||||
/*void load_file(string);
|
||||
/*void load_file(string);*/
|
||||
void load(string);
|
||||
void play();
|
||||
void pause();
|
||||
/*void pause();
|
||||
void stop();
|
||||
bool is_playing();*/
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "audio.h"
|
||||
|
||||
static string cur_file;
|
||||
//static GstState cur_state = GST_STATE_NULL;
|
||||
static GstState cur_state = GST_STATE_NULL;
|
||||
|
||||
/*static bool change_state(GstState new_state)
|
||||
static bool change_state(GstState new_state)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
ret = gst_element_set_state(GST_ELEMENT(player), new_state);
|
||||
|
@ -23,7 +23,7 @@ static string cur_file;
|
|||
}
|
||||
}
|
||||
|
||||
static void reset()
|
||||
/*static void reset()
|
||||
{
|
||||
cur_file = "";
|
||||
change_state(GST_STATE_NULL);
|
||||
|
@ -42,15 +42,16 @@ void load_file(GstElement *playbin, string file)
|
|||
namespace libsaria
|
||||
{
|
||||
|
||||
/*void audio::play()
|
||||
void audio::play()
|
||||
{
|
||||
if (cur_file == "")
|
||||
return;
|
||||
if (change_state(GST_STATE_PLAYING))
|
||||
trigger_callback(PLAY);
|
||||
change_state(GST_STATE_PLAYING);
|
||||
/*if (change_state(GST_STATE_PLAYING))
|
||||
trigger_callback(PLAY);*/
|
||||
}
|
||||
|
||||
void audio::pause()
|
||||
/*void audio::pause()
|
||||
{
|
||||
if (cur_file == "")
|
||||
return;
|
||||
|
@ -69,17 +70,14 @@ namespace libsaria
|
|||
return;
|
||||
pause();
|
||||
seek_to(0);
|
||||
}
|
||||
}*/
|
||||
|
||||
void audio::load(string file)
|
||||
{
|
||||
if (file == "")
|
||||
return;
|
||||
reset();
|
||||
load_file(player, file);
|
||||
}
|
||||
|
||||
string audio::get_current_file()
|
||||
/*string audio::get_current_file()
|
||||
{
|
||||
return cur_file;
|
||||
}*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker.
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/print.h>
|
||||
/*#include <libsaria/library.h>
|
||||
#include <libsaria/index.h>*/
|
||||
|
@ -80,6 +81,8 @@ namespace libsaria
|
|||
void Track::play_now()
|
||||
{
|
||||
println("Playing: " + title + " by " + artist);
|
||||
audio::load(filepath);
|
||||
audio::play();
|
||||
}
|
||||
|
||||
/* Track::Track()
|
||||
|
|
Loading…
Reference in New Issue