Christine improvements
class discoverer:
def __init__(self):
print "discoverer: new instance"
self.discoverer = gst.element_factory_make("playbin")
self.discoverer.set_property("audio-sink",gst.element_factory_make("esdsink"))
self.discoverer.set_property("video-sink",gst.element_factory_make("xvimagesink"))
self.discoverer.set_property("volume",0.0)
self.bus = self.discoverer.get_bus()
def set_location(self,file):
self.tags = {}
self.discoverer.set_property("uri","file://%s"%file)
self.discoverer.set_state(gst.STATE_READY)
self.discoverer.set_state(gst.STATE_PAUSED)
self.discoverer.set_state(gst.STATE_PLAYING)
self.discoverer.set_state(gst.STATE_PAUSED)
def found_tags_cb(self,tags):
if len(tags.keys()) > 0:
for i in tags.keys():
self.tags[i] = tags[i]
#print self.tags
def get_location(self):
path = self.discoverer.get_property("uri")
if path != None:
path = path[7:]
return path
def get_tag(self,key):
try:
return self.tags[key]
except:
return ""
Cabe mencionar que en esta clase, es necesario conectar el bus (self.discoverer.bus) con un manejador para que cuando se envie el mensaje gst.MESSAGE_TAG utilice el metodo parse_tag propio del mensaje y que estos tags sean enviados a discoverer.found_tags_cb.
def message_handler(self,a,b):
d = self.discoverer
t = b.type
if t == gst.MESSAGE_TAG:
self.discoverer.found_tags_cb(b.parse_tag())





