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
69 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
75 self.updateTimer.start(500)
77 self.updateTimer.start(10000)
81 self.updateTimer.stop()
84 class ServicePositionGauge(PerServiceBase):
85 def __init__(self, navcore):
86 PerServiceBase.__init__(self, navcore,
88 iPlayableService.evStart: self.newService,
89 iPlayableService.evEnd: self.stopEvent,
90 iPlayableService.evCuesheetChanged: self.newCuesheet
95 if self.get() is None:
98 self.enablePolling(interval=500)
102 service = self.navcore.getCurrentService()
103 seek = service and service.seek()
107 len = seek.getLength()
108 pos = seek.getPlayPosition()
112 return (len[1], pos[1])
119 if self.instance is not None:
120 self.instance.setLength(data[0])
121 self.instance.setPosition(data[1])
124 self.disablePolling()
126 GUI_WIDGET = ePositionGauge
128 def postWidgetCreate(self, instance):
131 def newCuesheet(self):
132 service = self.navcore.getCurrentService()
133 cue = service and service.cueSheet()
134 cutlist = (cue and cue.getCutList()) or [ ]
135 if self.instance is not None:
136 self.instance.setInOutList(cutlist)