1 from PerServiceDisplay import PerServiceDisplay, PerServiceBase
2 from enigma import eTimer, iPlayableService, iSeekableServicePtr, ePositionGauge
5 class ServicePosition(PerServiceDisplay):
11 def __init__(self, navcore, type):
12 self.updateTimer = eTimer()
13 self.updateTimer.timeout.get().append(self.update)
14 PerServiceDisplay.__init__(self, navcore,
16 iPlayableService.evStart: self.newService,
17 iPlayableService.evEnd: self.stopEvent
20 self.relative_base = 0
24 self.setType(self.type)
26 def setType(self, type):
29 self.updateTimer.start(500)
32 def setRelative(self, rel):
33 self.relative_base = rel
36 service = self.navcore.getCurrentService()
37 seek = service and service.seek()
39 if what == self.TYPE_LENGTH:
41 elif what == self.TYPE_POSITION:
42 r = seek.getPlayPosition()
50 service = self.navcore.getCurrentService()
55 if self.type != self.TYPE_RELATIVE:
56 if self.type == self.TYPE_LENGTH:
57 l = self.get(self.TYPE_LENGTH)
58 elif self.type == self.TYPE_POSITION:
59 l = self.get(self.TYPE_POSITION)
60 elif self.type == self.TYPE_REMAINING:
61 l = self.get(self.TYPE_LENGTH) - self.get(self.TYPE_POSITION)
63 self.setText("%d:%02d" % (l/60, l%60))
65 l = self.get(self.TYPE_POSITION)
67 l += self.relative_base
70 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
78 self.updateTimer.start(500)
80 self.updateTimer.start(10000)
84 self.updateTimer.stop()
87 class ServicePositionGauge(PerServiceBase):
88 def __init__(self, navcore):
89 PerServiceBase.__init__(self, navcore,
91 iPlayableService.evStart: self.newService,
92 iPlayableService.evEnd: self.stopEvent,
93 iPlayableService.evCuesheetChanged: self.newCuesheet
98 if self.get() is None:
101 self.enablePolling(interval=500)
105 service = self.navcore.getCurrentService()
106 seek = service and service.seek()
110 len = seek.getLength()
111 pos = seek.getPlayPosition()
115 return (len[1], pos[1])
122 if self.instance is not None:
123 self.instance.setLength(data[0])
124 self.instance.setPosition(data[1])
127 self.disablePolling()
129 GUI_WIDGET = ePositionGauge
131 def postWidgetCreate(self, instance):
134 def newCuesheet(self):
135 service = self.navcore.getCurrentService()
136 cue = service and service.cueSheet()
137 cutlist = (cue and cue.getCutList()) or [ ]
138 if self.instance is not None:
139 self.instance.setInOutList(cutlist)