gstreamer/examples/gst/player.py
Johan Dahlin 15f1eb48cf gst/gstmodule.c (init_gst): Add constants for GST_*SECOND.
Original commit message from CVS:
* gst/gstmodule.c (init_gst): Add constants for GST_*SECOND.
(python_do_pending_calls): New idler handler, similar to pygtk, so
python events (eg KeyboardInterrupt) can be raised during mainloop

* gst/gst.override (_wrap_gst_bin_get_list):
(_wrap_gst_pad_tp_repr, caps_length, caps_item)
(structure_length, structure_subscript)
(_wrap_gst_structure_tp_repr): Impl.
(_wrap_gst_main): Override with threading blocking.

* gst/gst-types.defs (Object): add flags field.
(Structure): Add copy/release funcs

* gst/__init__.py (devloc): Don't initialize threads

* gst/Makefile.am: clean up

* examples/gst/player.py: Prettify and simplify. Uses GstThread now.

* examples/gstplay/player.py: Update to new api and make it work.
2004-03-24 10:31:35 +00:00

48 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python
import os
import sys
import gst
def found_tags_cb(element, source, tags):
for tag in tags.keys():
print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])
def error_cb(*args):
print args
def playfile(filename):
bin = gst.Thread('player')
bin.connect('eos', lambda x: gst.main_quit())
bin.connect('error', error_cb)
source = gst.Element('filesrc', 'src')
source.set_property('location', filename)
spider = gst.Element('spider', 'spider')
spider.connect('found-tag', found_tags_cb)
sink = gst.Element('osssink', 'sink')
#sink.set_property('release-device', 1)
bin.add_many(source, spider, sink)
if not gst.element_link_many(source, spider, sink):
print "ERROR: could not link"
return 2
print 'Playing:', os.path.basename(filename)
if not bin.set_state(gst.STATE_PLAYING):
print "ERROR: could not set bin to playing"
return 2
gst.main()
def main(args):
if len(args) != 2:
print 'Usage; player.py filename'
return 1
return playfile(args[1])
if __name__ == '__main__':
sys.exit(main(sys.argv))