-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# A simple looping player.
# Version 2, based on "about-to-finish" handling.
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, uri):
self._uri = uri
- self._player = Gst.ElementFactory.make("playbin", "player")
+ self._player = Gst.ElementFactory.make("playbin3", "player")
self._player.set_property("uri", uri)
self._player.connect("about-to-finish", self.on_about_to_finish)
def run(self):
self._player.set_state(Gst.State.PLAYING)
- self.loop = GObject.MainLoop()
+ self.loop = GLib.MainLoop()
self.loop.run()
def quit(self):
def on_error(self, bus, msg):
(err, debug) = msg.parse_error()
- print "Error: %s" % err, debug
+ print("Error: %s" % err, debug)
self.quit()