audio: Give the Player a playpause() function
This makes it easy for others to pause if playing, or play if paused Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
f55ecf0472
commit
e24999bb2f
|
@ -100,6 +100,12 @@ class Player:
|
|||
def play(self, *args):
|
||||
self.playbin.set_state(Gst.State.PLAYING)
|
||||
|
||||
def playpause(self, *args):
|
||||
if self.get_state() == Gst.State.PLAYING:
|
||||
self.pause()
|
||||
else:
|
||||
self.play()
|
||||
|
||||
def play_track(self, track):
|
||||
if track == self.track:
|
||||
return False
|
||||
|
|
|
@ -81,6 +81,12 @@ class TestPlayer(unittest.TestCase):
|
|||
play.play()
|
||||
self.assertEqual(play.get_state(), Gst.State.PLAYING)
|
||||
|
||||
play.playpause()
|
||||
self.assertEqual(play.get_state(), Gst.State.PAUSED)
|
||||
|
||||
play.playpause()
|
||||
self.assertEqual(play.get_state(), Gst.State.PLAYING)
|
||||
|
||||
play.pause()
|
||||
self.assertEqual(play.get_state(), Gst.State.PAUSED)
|
||||
|
||||
|
|
Loading…
Reference in New Issue