1 from PerServiceDisplay import PerServiceDisplay, PerServiceBase
2 from Components.GUIComponent import GUIComponent
3 from enigma import eTimer, iPlayableService, iSeekableServicePtr, ePositionGauge
6 class ServicePosition(PerServiceDisplay):
12 def __init__(self, navcore, type):
13 self.updateTimer = eTimer()
14 self.updateTimer.timeout.get().append(self.update)
15 PerServiceDisplay.__init__(self, navcore,
17 iPlayableService.evStart: self.newService,
18 iPlayableService.evEnd: self.stopEvent
21 self.relative_base = 0
25 self.setType(self.type)
27 def setType(self, type):
30 self.updateTimer.start(500)
33 def setRelative(self, rel):
34 self.relative_base = rel
37 service = self.navcore.getCurrentService()
38 seek = service and service.seek()
40 if what == self.TYPE_LENGTH:
42 elif what == self.TYPE_POSITION:
43 r = seek.getPlayPosition()
51 service = self.navcore.getCurrentService()
56 if self.type != self.TYPE_RELATIVE:
57 if self.type == self.TYPE_LENGTH:
58 l = self.get(self.TYPE_LENGTH)
59 elif self.type == self.TYPE_POSITION:
60 l = self.get(self.TYPE_POSITION)
61 elif self.type == self.TYPE_REMAINING:
62 l = self.get(self.TYPE_LENGTH) - self.get(self.TYPE_POSITION)
64 self.setText("%d:%02d" % (l/60, l%60))
66 l = self.get(self.TYPE_POSITION)
68 l += self.relative_base
71 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
79 self.updateTimer.start(500)
81 self.updateTimer.start(10000)
85 self.updateTimer.stop()
88 class ServicePositionGauge(PerServiceBase, GUIComponent):
89 def __init__(self, navcore):
90 GUIComponent.__init__(self)
91 PerServiceBase.__init__(self, navcore,
93 iPlayableService.evStart: self.newService,
94 iPlayableService.evEnd: self.stopEvent,
95 iPlayableService.evCuesheetChanged: self.newCuesheet
100 if self.get() is None:
101 self.disablePolling()
103 self.enablePolling(interval=500)
107 service = self.navcore.getCurrentService()
108 seek = service and service.seek()
112 len = seek.getLength()
113 pos = seek.getPlayPosition()
117 return (len[1], pos[1])
124 if self.instance is not None:
125 self.instance.setLength(data[0])
126 self.instance.setPosition(data[1])
129 self.disablePolling()
131 GUI_WIDGET = ePositionGauge
133 def postWidgetCreate(self, instance):
136 def newCuesheet(self):
137 service = self.navcore.getCurrentService()
138 cue = service and service.cueSheet()
139 cutlist = (cue and cue.getCutList()) or [ ]
140 if self.instance is not None:
141 self.instance.setInOutList(cutlist)