3 # Get a test sample with:
4 # youtube-dl -t http://www.youtube.com/watch?v=yWa-YXiSk2Y
15 def __init__(self, filename):
16 self._filename = filename
18 self._player = gst.element_factory_make("playbin2", "player")
19 self._player.set_property("uri", filename)
21 bus = self._player.get_bus()
22 bus.add_signal_watch()
23 bus.connect('message::eos', self.on_eos)
26 self._player.set_state(gst.STATE_PLAYING)
27 loop = gobject.MainLoop()
30 def on_eos(self, bus, msg):
32 self._player.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, 0)
37 sys.stdout.write("usage: %s <URI-OF-MEDIA-FILE>\n" % args[0])
43 if not gst.uri_is_valid(args[1]):
44 sys.stderr.write("Error: Invalid URI: %s\n" % args[1])
47 player = Player(args[1])
50 if __name__ == '__main__':
51 sys.exit(main(sys.argv))