libsaria: Preserve the current playback state when changing tracks
This makes something new play when we want it to... Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
4f68e6b26d
commit
53425485d6
|
@ -5,7 +5,7 @@
|
|||
#include <libsaria/path.h>
|
||||
#include "audio.h"
|
||||
|
||||
static GstState cur_state = GST_STATE_NULL;
|
||||
static GstState cur_state = GST_STATE_READY;
|
||||
|
||||
static bool change_state(GstState new_state)
|
||||
{
|
||||
|
@ -30,11 +30,17 @@ static bool change_state(GstState new_state)
|
|||
|
||||
void load_file(GstElement *playbin, string file)
|
||||
{
|
||||
GstState state = cur_state;
|
||||
|
||||
if (file == "" || !exists(file))
|
||||
return;
|
||||
|
||||
string uri = "file://" + file;
|
||||
println("Loading uri: " + uri);
|
||||
/* Preserve the current playback state */
|
||||
change_state(GST_STATE_READY);
|
||||
g_object_set(G_OBJECT(playbin), "uri", uri.c_str(), NULL);
|
||||
change_state(state);
|
||||
}
|
||||
|
||||
namespace libsaria
|
||||
|
|
Loading…
Reference in New Issue