python: update python examples to modern python, Gst, and Glib versions
[experiments/gstreamer.git] / python / gst-looping-video-1.py
index 7d1cc3f..7d8bd01 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # A simple looping player.
 # Version 1, based on EOS handling.
@@ -13,8 +13,7 @@ gi.require_version('Gst', '1.0')
 from gi.repository import Gst
 Gst.init(None)
 
-from gi.repository import GObject
-GObject.threads_init()
+from gi.repository import GLib
 
 
 class Player:
@@ -29,7 +28,7 @@ class Player:
 
     def run(self):
         self._player.set_state(Gst.State.PLAYING)
-        self.loop = GObject.MainLoop()
+        self.loop = GLib.MainLoop()
         self.loop.run()
 
     def quit(self):
@@ -42,7 +41,7 @@ class Player:
 
     def on_error(self, bus, msg):
         (err, debug) = msg.parse_error()
-        print "Error: %s" % err, debug
+        print("Error: %s" % err, debug)
         self.quit()