from gi.repository import Gst
Gst.init(None)
-from gi.repository import GObject
-GObject.threads_init()
+from gi.repository import GLib
class Player:
def __init__(self):
- self.loop = GObject.MainLoop()
- self.pipeline = Gst.ElementFactory.make("playbin", "player")
+ self.loop = GLib.MainLoop()
+ self.pipeline = Gst.ElementFactory.make("playbin3", "player")
files = ["sample_440hz.webm", "sample_880hz.webm"]
self.uris = [Gst.filename_to_uri(f) for f in files]
self.pipeline.set_state(Gst.State.NULL)
self.loop.quit()
- def switch(self):
+ def on_switch(self):
self.uri_index ^= 1
print("Next: %s" % self.uris[self.uri_index])
def stdin_cb(source, condition):
source.readline()
- player.switch()
+ player.on_switch()
return True
- GObject.io_add_watch(sys.stdin, GObject.IO_IN, stdin_cb)
+ GLib.io_add_watch(sys.stdin, GLib.IO_IN, stdin_cb)
print("\nPress Enter to switch the source\n")
player.run()