1 """Wrapper around vlc module in order to ease the use of vlc.Object
2 class (completion in ipython, access variable as attributes, etc).
6 class VLCObject(object):
7 def __init__(self, id):
8 object.__setattr__(self, '_o', vlc.Object(id))
11 t=self._o.find_object(typ)
13 return VLCObject(t.info()['object-id'])
19 return "VLCObject %d (%s) : %s" % (i['object-id'],
23 def tree(self, prefix=" "):
24 """Displays the children as a tree."""
26 for i in self._o.children():
28 t.tree(prefix=prefix + " ")
31 def __getattribute__(self, attr):
32 #print "Getting %s" % attr
33 if attr == '__members__':
34 o=object.__getattribute__(self, '_o')
36 l.extend([ n.replace('-','_') for n in o.list() ])
39 return object.__getattribute__ (self, attr)
40 except AttributeError, e:
42 return self._o.__getattribute__ (attr)
43 except AttributeError, e:
44 attr=attr.replace('_', '-')
45 if attr in self._o.list():
46 return self._o.get(attr)
50 def __setattr__(self, name, value):
51 n=name.replace('_', '-')
52 if n in self._o.list():
55 object.__setattr__(self, name, value)
57 #mc=vlc.MediaControl()
58 #mc.playlist_add_item('/tmp/k.mpg')
64 mc.playlist_add_item('/tmp/k.mpg')