1 from PerServiceDisplay import PerServiceDisplay, PerServiceBase
2 from Components.GUIComponent import GUIComponent
3 from enigma import eTimer, iPlayableService, ePositionGauge
6 class ServicePosition(PerServiceDisplay, object):
12 def __init__(self, navcore, type):
14 self.updateTimer = eTimer()
15 self.updateTimer.timeout.get().append(self.update)
16 PerServiceDisplay.__init__(self, navcore,
18 iPlayableService.evStart: self.newService,
19 iPlayableService.evEnd: self.stopEvent
22 self.relative_base = 0
26 self.setType(self.type)
28 def setType(self, type):
31 self.updateTimer.start(500)
34 def setRelative(self, rel):
35 self.relative_base = rel
38 service = self.navcore.getCurrentService()
39 seek = service and service.seek()
41 if what == self.TYPE_LENGTH:
43 elif what == self.TYPE_POSITION:
44 r = seek.getPlayPosition()
52 service = self.navcore.getCurrentService()
57 if self.type != self.TYPE_RELATIVE:
58 if self.type == self.TYPE_LENGTH:
59 l = self.get(self.TYPE_LENGTH)
60 elif self.type == self.TYPE_POSITION:
61 l = self.get(self.TYPE_POSITION)
62 elif self.type == self.TYPE_REMAINING:
63 l = self.get(self.TYPE_LENGTH) - self.get(self.TYPE_POSITION)
65 self.setText("%d:%02d" % (l/60, l%60))
67 l = self.get(self.TYPE_POSITION)
69 l += self.relative_base
72 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
80 self.updateTimer.start(500)
82 self.updateTimer.start(10000)
86 self.updateTimer.stop()
89 class ServicePositionGauge(PerServiceBase, GUIComponent):
90 def __init__(self, navcore):
91 GUIComponent.__init__(self)
92 PerServiceBase.__init__(self, navcore,
94 iPlayableService.evStart: self.newService,
95 iPlayableService.evEnd: self.stopEvent,
96 iPlayableService.evCuesheetChanged: self.newCuesheet
99 self.__seek_position = 0
101 def newService(self):
102 if self.get() is None:
103 self.disablePolling()
105 self.enablePolling(interval=500)
109 service = self.navcore.getCurrentService()
110 seek = service and service.seek()
114 len = seek.getLength()
115 pos = seek.getPlayPosition()
119 return (len[1], pos[1])
126 if self.instance is not None:
127 self.instance.setLength(data[0])
128 self.instance.setPosition(data[1])
131 self.disablePolling()
133 GUI_WIDGET = ePositionGauge
135 def postWidgetCreate(self, instance):
137 self.setSeekPosition(self.__seek_position)
139 def newCuesheet(self):
140 service = self.navcore.getCurrentService()
141 cue = service and service.cueSheet()
142 cutlist = (cue and cue.getCutList()) or [ ]
143 if self.instance is not None:
144 self.instance.setInOutList(cutlist)
146 def getSeekEnable(self):
147 return self.__seek_enable
149 def setSeekEnable(self, val):
150 self.__seek_enable = val
151 if self.instance is not None:
152 self.instance.enableSeekPointer(val)
154 seek_pointer_enabled = property(getSeekEnable, setSeekEnable)
156 def getSeekPosition(self):
157 return self.__seek_position
159 def setSeekPosition(self, pos):
160 print "set seek position:", pos
161 self.__seek_position = pos
162 if self.instance is not None:
163 print "set instance."
164 self.instance.setSeekPosition(pos)
166 seek_pointer_position = property(getSeekPosition, setSeekPosition)