libsaria: Track current gstreamer state
I use this to tell the GUI if music is currently playing or not.
This commit is contained in:
parent
b75deae1a2
commit
81e7662c7e
|
@ -20,6 +20,7 @@ namespace libsaria
|
|||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
bool is_playing();
|
||||
|
||||
/* Position related functions */
|
||||
bool seek(int);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "audio.h"
|
||||
|
||||
static string cur_file;
|
||||
static GstState cur_state = GST_STATE_NULL;
|
||||
|
||||
static bool change_state(GstState new_state)
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ static bool change_state(GstState new_state)
|
|||
switch(ret) {
|
||||
case GST_STATE_CHANGE_SUCCESS:
|
||||
case GST_STATE_CHANGE_ASYNC:
|
||||
cur_state = new_state;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -44,6 +46,11 @@ namespace libsaria
|
|||
trigger_callback(PAUSE);
|
||||
}
|
||||
|
||||
bool audio::is_playing()
|
||||
{
|
||||
return cur_state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
void audio::stop()
|
||||
{
|
||||
pause();
|
||||
|
|
Loading…
Reference in New Issue