1 from Converter import Converter
3 from enigma import iPlayableService
4 from Components.Element import cached, ElementError
6 class ServicePosition(Converter, Poll, object):
12 def __init__(self, type):
14 Converter.__init__(self, type)
16 args = type.split(',')
19 self.negate = 'Negate' in args
20 self.detailed = 'Detailed' in args
21 self.showHours = 'ShowHours' in args
22 self.showNoSeconds = 'ShowNoSeconds' in args
25 self.poll_interval = 100
27 self.poll_interval = 500
30 self.type = self.TYPE_LENGTH
31 elif type == "Position":
32 self.type = self.TYPE_POSITION
33 elif type == "Remaining":
34 self.type = self.TYPE_REMAINING
36 self.type = self.TYPE_GAUGE
38 raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}")
40 self.poll_enabled = self.type != self.TYPE_LENGTH
43 s = self.source.service
47 def getPosition(self):
51 pos = seek.getPlayPosition()
61 length = seek.getLength()
68 service = self.source.service
69 cue = service and service.cueSheet()
70 return cue and cue.getCutList()
78 if self.type == self.TYPE_LENGTH:
80 elif self.type == self.TYPE_POSITION:
82 elif self.type == self.TYPE_REMAINING:
83 l = self.length - self.position
88 if self.negate: l = -l
98 if self.showNoSeconds:
99 return sign + "%d:%02d" % (l/3600, l%3600/60)
101 return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
103 if self.showNoSeconds:
104 return sign + "%d" % (l/60)
106 return sign + "%d:%02d" % (l/60, l%60)
109 return sign + "%d:%02d:%02d:%03d" % ((l/3600/90000), (l/90000)%3600/60, (l/90000)%60, (l%90000)/90)
111 return sign + "%d:%02d:%03d" % ((l/60/90000), (l/90000)%60, (l%90000)/90)
113 # range/value are for the Progress renderer
120 if pos is None or len is None or len <= 0:
122 return pos * 10000 / len
124 position = property(getPosition)
125 length = property(getLength)
126 cutlist = property(getCutlist)
127 text = property(getText)
128 value = property(getValue)
130 def changed(self, what):
131 cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged]
132 time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged]
135 if self.type == self.TYPE_GAUGE:
136 self.downstream_elements.cutlist_changed()
139 self.downstream_elements.changed(what)