1 from Screen import Screen
2 from ChannelSelection import ChannelSelection
3 from Components.Clock import Clock
4 from Components.ActionMap import ActionMap
5 from Components.Button import Button
6 from Components.ServiceName import ServiceName
7 from Components.EventInfo import EventInfo
8 from Components.ServicePosition import ServicePosition
9 from Components.config import configfile
11 from Screens.MessageBox import MessageBox
12 from Screens.MovieSelection import MovieSelection
13 from Screens.Volume import Volume
20 from Menu import MainMenu, mdom
22 class InfoBar(Screen):
28 def __init__(self, session):
29 Screen.__init__(self, session)
32 self.servicelist = self.session.instantiateDialog(ChannelSelection)
34 self.state = self.STATE_HIDDEN
36 self.volumeDialog = self.session.instantiateDialog(Volume)
38 self.hideTimer = eTimer()
39 self.hideTimer.timeout.get().append(self.doTimerHide)
40 #self.hideTimer.start(1000)
43 self["actions"] = ActionMap( [ "InfobarActions" ],
45 "switchChannelUp": self.switchChannelUp,
46 "switchChannelDown": self.switchChannelDown,
47 "mainMenu": self.mainMenu,
49 "zapDown": self.zapDown,
50 "volumeUp": self.volUp,
51 "volumeDown": self.volDown,
52 "volumeMute": self.volMute,
53 "instantRecord": self.instantRecord,
55 "toggleShow": self.toggleShow,
56 "showMovies": self.showMovies,
59 # self["okbutton"] = Button("mainMenu", [self.mainMenu])
61 self["CurrentTime"] = Clock()
62 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
65 self["ServiceName"] = ServiceName(self.session.nav)
67 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
68 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
70 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
71 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
78 print "loading mainmenu XML..."
79 menu = mdom.childNodes[0]
80 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
81 self.session.open(MainMenu, menu, menu.childNodes)
83 def switchChannelUp(self):
84 self.servicelist.moveUp()
85 self.session.execDialog(self.servicelist)
87 def switchChannelDown(self):
88 self.servicelist.moveDown()
89 self.session.execDialog(self.servicelist)
94 def doTimerHide(self):
95 if self.state == self.STATE_SHOWN:
97 self.state = self.STATE_HIDDEN
100 if self.state == self.STATE_SHOWN:
102 #pls check animation support, sorry
104 self.state = self.STATE_HIDDEN
108 self.state = self.STATE_SHOWN
109 #TODO: make it customizable
110 self.hideTimer.start(5000)
113 self.servicelist.moveUp()
114 self.servicelist.zap()
117 self.servicelist.moveDown()
118 self.servicelist.zap()
121 eDVBVolumecontrol.getInstance().volumeUp()
122 self.volumeDialog.instance.show()
123 # FIXME: help wanted :)
124 self.volumeDialog.instance.setValue(eDVBVolumecontrol.getInstance().getVolume())
125 self.hideVolTimer = eTimer()
126 self.hideVolTimer.timeout.get().append(self.volHide)
127 self.hideVolTimer.start(3000)
130 eDVBVolumecontrol.getInstance().volumeDown()
131 self.volumeDialog.instance.show()
132 # FIXME: help wanted :)
133 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
134 self.hideVolTimer = eTimer()
135 self.hideVolTimer.timeout.get().append(self.volHide)
136 self.hideVolTimer.start(3000)
139 self.volumeDialog.instance.hide()
142 self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
143 self.state = self.STATE_SHOWN
146 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
147 self.state = self.STATE_HIDDEN
150 eDVBVolumecontrol.getInstance().volumeToggleMute()
151 self.volumeBar.setValue(eDVBVolumecontrol.getInstance().getVolume())
157 def stopCurrentRecording(self):
159 self.session.nav.RecordTimer.removeEntry(self.recording)
160 self.recording = None
162 def startInstantRecording(self):
163 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
165 # try to get event info
168 service = self.session.nav.getCurrentService()
169 info = service.info()
170 ev = info.getEvent(0)
175 # fix me, description.
176 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg, "instant record")
178 def recordQuestionCallback(self, answer):
182 if self.recording != None:
183 self.stopCurrentRecording()
185 self.startInstantRecording()
187 def instantRecord(self):
188 if self.recording != None:
189 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Do you want to stop the current\n(instant) recording?")
191 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Start recording?")
193 def showMovies(self):
194 self.session.open(MovieSelection)