1 from Tools.Profile import profile
3 # workaround for required config entry dependencies.
4 from Screens.MovieSelection import MovieSelection
6 from Screen import Screen
9 from enigma import iPlayableService
11 profile("LOAD:InfoBarGenerics")
12 from Screens.InfoBarGenerics import InfoBarShowHide, \
13 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarRdsDecoder, \
14 InfoBarEPG, InfoBarSeek, InfoBarInstantRecord, InfoBarRedButton, \
15 InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarUnhandledKey, \
16 InfoBarSubserviceSelection, InfoBarShowMovies, InfoBarTimeshift, \
17 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
18 InfoBarSummarySupport, InfoBarMoviePlayerSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
19 InfoBarSubtitleSupport, InfoBarPiP, InfoBarPlugins, InfoBarServiceErrorPopupSupport, InfoBarJobman, \
22 profile("LOAD:InitBar_Components")
23 from Components.ActionMap import HelpableActionMap
24 from Components.config import config
25 from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
27 profile("LOAD:HelpableScreen")
28 from Screens.HelpMenu import HelpableScreen
30 class InfoBar(InfoBarBase, InfoBarShowHide,
31 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, InfoBarRdsDecoder,
32 InfoBarInstantRecord, InfoBarAudioSelection, InfoBarRedButton,
33 HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarUnhandledKey,
34 InfoBarSubserviceSelection, InfoBarTimeshift, InfoBarSeek,
35 InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions,
36 InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, InfoBarServiceErrorPopupSupport, InfoBarJobman,
42 def __init__(self, session):
43 Screen.__init__(self, session)
44 self["actions"] = HelpableActionMap(self, "InfobarActions",
46 "showMovies": (self.showMovies, _("Play recorded movies...")),
47 "showRadio": (self.showRadio, _("Show the radio player...")),
48 "showTv": (self.showTv, _("Show the tv player...")),
49 "showSubtitle":(self.showSubtitle, _("Show the Subtitle...")),
54 for x in HelpableScreen, \
55 InfoBarBase, InfoBarShowHide, \
56 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, InfoBarRdsDecoder, \
57 InfoBarInstantRecord, InfoBarAudioSelection, InfoBarRedButton, InfoBarUnhandledKey, \
58 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
59 InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
60 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, InfoBarJobman, \
61 InfoBarPlugins, InfoBarServiceErrorPopupSupport, InfoBarHDMI:
64 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
65 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", _("hear radio..."))]))
67 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
69 iPlayableService.evUpdatedEventInfo: self.__eventInfoChanged
72 self.current_begin_time=0
73 assert InfoBar.instance is None, "class InfoBar is a singleton class and just one instance of this class is allowed!"
74 InfoBar.instance = self
77 InfoBar.instance = None
79 def __eventInfoChanged(self):
81 service = self.session.nav.getCurrentService()
82 old_begin_time = self.current_begin_time
83 info = service and service.info()
84 ptr = info and info.getEvent(0)
85 self.current_begin_time = ptr and ptr.getBeginTime() or 0
86 if config.usage.show_infobar_on_event_change.value:
87 if old_begin_time and old_begin_time != self.current_begin_time:
90 def __checkServiceStarted(self):
91 self.__serviceStarted(True)
92 self.onExecBegin.remove(self.__checkServiceStarted)
94 def serviceStarted(self): #override from InfoBarShowHide
95 new = self.servicelist.newServicePlayed()
97 InfoBarShowHide.serviceStarted(self)
98 self.current_begin_time=0
99 elif not self.__checkServiceStarted in self.onShown and new:
100 self.onShown.append(self.__checkServiceStarted)
102 def __checkServiceStarted(self):
103 self.serviceStarted()
104 self.onShown.remove(self.__checkServiceStarted)
107 self.showTvChannelList(True)
110 if config.usage.e1like_radio_mode.value:
111 self.showRadioChannelList(True)
113 self.rds_display.hide() # in InfoBarRdsDecoder
114 from Screens.ChannelSelection import ChannelSelectionRadio
115 self.session.openWithCallback(self.ChannelSelectionRadioClosed, ChannelSelectionRadio, self)
117 def ChannelSelectionRadioClosed(self, *arg):
118 self.rds_display.show() # in InfoBarRdsDecoder
120 def showMovies(self):
121 from Screens.MovieSelection import MovieSelection
122 self.session.openWithCallback(self.movieSelected, MovieSelection)
124 def movieSelected(self, service):
125 if service is not None:
126 self.session.open(MoviePlayer, service)
128 def showSubtitle(self):
129 from Screens.Subtitles import Subtitles
130 self.session.open(Subtitles)
132 class MoviePlayer(InfoBarBase, InfoBarShowHide, \
134 InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
135 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
136 InfoBarMoviePlayerSummarySupport, InfoBarSubtitleSupport, Screen, InfoBarTeletextPlugin,
137 InfoBarServiceErrorPopupSupport, InfoBarExtensions, InfoBarPlugins, InfoBarPiP, InfoBarHDMI):
139 ENABLE_RESUME_SUPPORT = True
142 def __init__(self, session, service):
143 Screen.__init__(self, session)
145 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
147 "showSubtitle":(self.showSubtitle, _("Show the Subtitle...")),
148 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
151 self.allowPiP = False
153 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
154 InfoBarBase, InfoBarSeek, InfoBarShowMovies, \
155 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
156 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
157 InfoBarMoviePlayerSummarySupport, InfoBarSubtitleSupport, \
158 InfoBarTeletextPlugin, InfoBarServiceErrorPopupSupport, InfoBarExtensions, \
159 InfoBarPlugins, InfoBarPiP:
162 self.lastservice = session.nav.getCurrentlyPlayingServiceReference()
163 session.nav.playService(service)
164 self.returning = False
165 self.onClose.append(self.__onClose)
168 self.session.nav.playService(self.lastservice)
170 def handleLeave(self, how):
171 self.is_closing = True
173 if config.usage.setup_level.index < 2: # -expert
176 (_("No"), "continue")
181 (_("Yes, returning to movie list"), "movielist"),
182 (_("Yes, and delete this movie"), "quitanddelete"),
183 (_("No"), "continue"),
184 (_("No, but restart from begin"), "restart")
187 from Screens.ChoiceBox import ChoiceBox
188 self.session.openWithCallback(self.leavePlayerConfirmed, ChoiceBox, title=_("Stop playing this movie?"), list = list)
190 self.leavePlayerConfirmed([True, how])
192 def leavePlayer(self):
193 self.handleLeave(config.usage.on_movie_stop.value)
195 def deleteConfirmed(self, answer):
197 self.leavePlayerConfirmed((True, "quitanddeleteconfirmed"))
199 def leavePlayerConfirmed(self, answer):
200 answer = answer and answer[1]
202 if answer in ("quitanddelete", "quitanddeleteconfirmed"):
203 ref = self.session.nav.getCurrentlyPlayingServiceReference()
204 from enigma import eServiceCenter
205 serviceHandler = eServiceCenter.getInstance()
206 info = serviceHandler.info(ref)
207 name = info and info.getName(ref) or _("this recording")
209 if answer == "quitanddelete":
210 from Screens.MessageBox import MessageBox
211 self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % name)
214 elif answer == "quitanddeleteconfirmed":
215 offline = serviceHandler.offlineOperations(ref)
216 if offline.deleteFromDisk(0):
217 from Screens.MessageBox import MessageBox
218 self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR)
221 if answer in ("quit", "quitanddeleteconfirmed"):
223 elif answer == "movielist":
224 ref = self.session.nav.getCurrentlyPlayingServiceReference()
225 self.returning = True
226 from Screens.MovieSelection import MovieSelection
227 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
228 self.session.nav.stopService()
229 elif answer == "restart":
231 self.setSeekState(self.SEEK_STATE_PLAY)
233 def doEofInternal(self, playing):
238 self.handleLeave(config.usage.on_movie_eof.value)
240 def showMovies(self):
241 ref = self.session.nav.getCurrentlyPlayingServiceReference()
242 from Screens.MovieSelection import MovieSelection
243 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
245 def movieSelected(self, service):
246 if service is not None:
247 self.is_closing = False
248 self.session.nav.playService(service)
249 self.returning = False
253 def showSubtitle(self):
254 from Screens.Subtitles import Subtitles
255 self.session.open(Subtitles)