rind: Respond to the playbin's about-to-finish signal
We use this to load the next track without changing the pipeline state, which should give us smoother audio switching. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
c447c9e2b7
commit
b9035abf8a
10
rind/gst.py
10
rind/gst.py
|
@ -31,8 +31,14 @@ class EmmentalAudio:
|
|||
NextButton.connect( "clicked", self.next)
|
||||
ProgScale.connect("change-value", self.seek)
|
||||
|
||||
self.playbin.connect("about-to-finish", self.about_to_finish)
|
||||
self.timeout = GLib.timeout_add(100, self.update_progress)
|
||||
|
||||
def about_to_finish(self, playbin):
|
||||
track = curds.PlaylistManager.next()
|
||||
if track:
|
||||
self.playbin.set_property("uri", f"file://{track.path}")
|
||||
|
||||
def duration(self):
|
||||
(res, cur) = self.playbin.query_duration(Gst.Format.TIME)
|
||||
return cur / Gst.SECOND if res == True else 0.0
|
||||
|
@ -44,9 +50,7 @@ class EmmentalAudio:
|
|||
self.playbin.set_state(Gst.State.PLAYING)
|
||||
|
||||
def next(self, *args):
|
||||
track = curds.PlaylistManager.next()
|
||||
if track != None:
|
||||
self.load(track)
|
||||
self.load(curds.PlaylistManager.next())
|
||||
|
||||
def on_message(self, bus, message):
|
||||
if message.type == Gst.MessageType.STATE_CHANGED:
|
||||
|
|
|
@ -139,3 +139,9 @@ class TestGst(unittest.TestCase):
|
|||
self.main_loop()
|
||||
self.assertTrue( gst.PauseButton.is_visible())
|
||||
self.assertFalse(gst.PlayButton.is_visible())
|
||||
|
||||
track = curds.PlaylistManager.track
|
||||
self.audio.seek(value=99)
|
||||
time.sleep(0.1)
|
||||
self.main_loop()
|
||||
self.assertNotEqual(curds.PlaylistManager.track, track)
|
||||
|
|
Loading…
Reference in New Issue