libsaria: Don't change audio pipeline state if no file loaded
I only want to change to gst.STATE_PLAYING or gst.STATE_PAUSED if the pipeline currently has a file loaded. Not doing this can cause an exception in position() when get_state() returns gst.STATE_READY instead of gst.STATE_NULL.
This commit is contained in:
parent
0f78c7b80c
commit
67369e88a7
|
@ -18,11 +18,20 @@ def load_file(type, file):
|
|||
reset()
|
||||
player.set_property("uri", "%s://%s" % (type, file))
|
||||
|
||||
def has_file():
|
||||
return player.get_property("uri") != None
|
||||
|
||||
def change_state(state):
|
||||
if has_file() == True:
|
||||
player.set_state(state)
|
||||
else:
|
||||
player.set_state(gst.STATE_NULL)
|
||||
|
||||
def play():
|
||||
player.set_state(gst.STATE_PLAYING)
|
||||
change_state(gst.STATE_PLAYING)
|
||||
|
||||
def pause():
|
||||
player.set_state(gst.STATE_PAUSED)
|
||||
change_state(gst.STATE_PAUSED)
|
||||
|
||||
def stop():
|
||||
pause()
|
||||
|
|
Loading…
Reference in New Issue