1 from Converter import Converter
3 from enigma import iPlayableService
4 from Components.Element import cached
6 class ServicePosition(Converter, Poll, object):
11 TYPE_POSITION_DETAILED = 4
13 def __init__(self, type):
15 Converter.__init__(self, type)
17 self.poll_interval = 500
20 self.type = self.TYPE_LENGTH
21 elif type == "Position":
22 self.type = self.TYPE_POSITION
23 elif type == "PositionDetailed":
24 self.type = self.TYPE_POSITION_DETAILED
25 self.poll_interval = 100
26 elif type == "Remaining":
27 self.type = self.TYPE_REMAINING
29 self.type = self.TYPE_GAUGE
31 raise "type must be {Length|Position|PositionDetaileed|Remaining|Gauge}"
33 self.poll_enabled = self.type != self.TYPE_LENGTH
36 s = self.source.service
40 def getPosition(self):
44 pos = seek.getPlayPosition()
54 length = seek.getLength()
61 service = self.source.service
62 cue = service and service.cueSheet()
63 return cue and cue.getCutList()
71 if self.type == self.TYPE_LENGTH:
73 elif self.type in [self.TYPE_POSITION, self.TYPE_POSITION_DETAILED]:
75 elif self.type == self.TYPE_REMAINING:
76 l = self.length - self.position
78 if self.type != self.TYPE_POSITION_DETAILED:
87 if self.type != self.TYPE_POSITION_DETAILED:
88 return sign + "%d:%02d" % (l/60, l%60)
90 return sign + "%d:%02d:%03d" % ((l/60/90000), (l/90000)%60, (l%90000)/90)
92 # range/value are for the Progress renderer
99 if pos is None or len is None or len <= 0:
101 return pos * 10000 / len
103 position = property(getPosition)
104 length = property(getLength)
105 cutlist = property(getCutlist)
106 text = property(getText)
107 value = property(getValue)
109 def changed(self, what):
110 cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged]
111 time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged]
114 if self.type == self.TYPE_GAUGE:
115 self.downstream_elements.cutlist_changed()
118 self.downstream_elements.changed(what)