(args)
| 21 | return True |
| 22 | |
| 23 | def main(args): |
| 24 | if len(args) != 2: |
| 25 | sys.stderr.write("usage: %s <media file or uri>\n" % args[0]) |
| 26 | sys.exit(1) |
| 27 | |
| 28 | playbin = gst.element_factory_make("playbin2", None) |
| 29 | if not playbin: |
| 30 | sys.stderr.write("'playbin2' 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_watch(bus_call, loop) |
| 45 | |
| 46 | # start play back and listed to events |
| 47 | playbin.set_state(gst.STATE_PLAYING) |
| 48 | loop.run() |
| 49 | |
| 50 | # cleanup |
| 51 | playbin.set_state(gst.STATE_NULL) |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | sys.exit(main(sys.argv)) |
no test coverage detected