MCPcopy Create free account
hub / github.com/GStreamer/gst-python / main

Function main

examples/helloworld.py:20–55  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

18 return True
19
20def main(args):
21 if len(args) != 2:
22 sys.stderr.write("usage: %s <media file or uri>\n" % args[0])
23 sys.exit(1)
24
25 GObject.threads_init()
26 Gst.init(None)
27
28 playbin = Gst.ElementFactory.make("playbin", None)
29 if not playbin:
30 sys.stderr.write("'playbin' gstreamer plugin missing\n")
31 sys.exit(1)
32
33 # take the commandline argument and ensure that it is a uri
34 if Gst.uri_is_valid(args[1]):
35 uri = args[1]
36 else:
37 uri = Gst.filename_to_uri(args[1])
38 playbin.set_property('uri', uri)
39
40 # create and event loop and feed gstreamer bus mesages to it
41 loop = GObject.MainLoop()
42
43 bus = playbin.get_bus()
44 bus.add_signal_watch()
45 bus.connect ("message", bus_call, loop)
46
47 # start play back and listed to events
48 playbin.set_state(Gst.State.PLAYING)
49 try:
50 loop.run()
51 except:
52 pass
53
54 # cleanup
55 playbin.set_state(Gst.State.NULL)
56
57if __name__ == '__main__':
58 sys.exit(main(sys.argv))

Callers 1

helloworld.pyFile · 0.70

Calls 3

makeMethod · 0.80
set_propertyMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected