(args)
| 18 | return True |
| 19 | |
| 20 | def 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 | |
| 57 | if __name__ == '__main__': |
| 58 | sys.exit(main(sys.argv)) |
no test coverage detected