1 from PerServiceDisplay import *
2 from time import strftime
3 from time import localtime, time
5 from enigma import iServiceInformationPtr, eServiceEventPtr
7 class EventInfo(PerServiceDisplay):
16 def __init__(self, navcore, now_or_next):
17 # listen to evUpdatedEventInfo and evEnd
18 # note that evEnd will be called once to establish a known state
19 self.now_or_next = now_or_next
20 PerServiceDisplay.__init__(self, navcore,
22 iPlayableService.evUpdatedEventInfo: self.ourEvent,
23 iPlayableService.evEnd: self.stopEvent
26 if now_or_next in [self.Now_Remaining]:
30 info = iServiceInformationPtr()
31 service = self.navcore.getCurrentService()
36 ev = info.getEvent(self.now_or_next & 1)
41 if self.now_or_next == self.Now_Remaining and ev.getBeginTime() <= time() <= (ev.getBeginTime() + ev.getDuration()):
42 self.setText("+%d min" % ((ev.getBeginTime() + ev.getDuration() - time()) / 60))
43 elif self.now_or_next in [self.Now_Duration, self.Next_Duration, self.Now_Remaining]:
44 self.setText("%d min" % (ev.getDuration() / 60))
45 elif self.now_or_next in [self.Now_StartTime, self.Next_StartTime]:
46 self.setText(strftime("%H:%M", localtime(ev.getBeginTime())))
47 elif self.now_or_next in [self.Now, self.Next]:
48 self.setText(ev.getEventName())
52 ("", "", "", "", "--:--", "--:--", "")[self.now_or_next]);
57 class EventInfoProgress(PerServiceDisplayProgress, EventInfo):
58 def __init__(self, navcore, now_or_next):
59 self.now_or_next = now_or_next
60 PerServiceDisplayProgress.__init__(self, navcore,
62 iPlayableService.evUpdatedEventInfo: self.ourEvent,
63 iPlayableService.evEnd: self.stopEvent
67 self.g.setRange(0, ev.getDuration())
68 progress = int(time() - ev.getBeginTime())
70 self.setValue(progress)