pygst: The "about-to-finish" event fails to play next song (gapless playing) in Python

Ralph Heinkel ralph.heinkel at web.de
Tue Dec 20 08:57:01 PST 2011


Hi,
following code ("stolen" from eurion.net...) does not replay the same 
song (or any other song) set in about_to_finish() event callback 
method. The event method is entered (verified by temporarily added 
print statements), but the player just stops after playing the first song.

I'm using (opensuse 12.1) linux, gstreamer 0.10.35, gst-python 0.10.22

Am I missing anything? Any help would be appreciated.

Thanks,

Ralph

------------------------------------------
#!/usr/bin/python
# code from 
http://www.eurion.net/python-snippets/snippet/Gapless%20playback.html
import pygst
pygst.require("0.10")
import gst, sys, gobject

class Player:
     def __init__(self, filename):
         self.filename = filename
         self.player = gst.element_factory_make("playbin2", "player")
         self.player.set_property("uri", filename)
         self.player.connect("about-to-finish", self.about_to_finish)

     def run(self):
         self.player.set_state(gst.STATE_PLAYING)
         loop = gobject.MainLoop()
         loop.run()

     def about_to_finish(self, player):
         player.set_property("uri", self.filename)

if __name__ == "__main__":
     gobject.threads_init()
     player = Player("file:///path/to/song.ogg")
     player.run()




More information about the gstreamer-devel mailing list