1 from ChannelSelection import ChannelSelection, BouquetSelector
3 from Components.ActionMap import ActionMap, HelpableActionMap
4 from Components.ActionMap import NumberActionMap
5 from Components.BlinkingPixmap import BlinkingPixmapConditional
6 from Components.Harddisk import harddiskmanager
7 from Components.Input import Input
8 from Components.Label import Label
9 from Components.Pixmap import Pixmap
10 from Components.PluginComponent import plugins
11 from Components.ServiceEventTracker import ServiceEventTracker
12 from Components.Sources.Source import ObsoleteSource
13 from Components.Sources.Boolean import Boolean
14 from Components.config import config, ConfigBoolean, ConfigClock
15 from EpgSelection import EPGSelection
16 from Plugins.Plugin import PluginDescriptor
18 from Screen import Screen
19 from Screens.ChoiceBox import ChoiceBox
20 from Screens.Dish import Dish
21 from Screens.EventView import EventViewEPGSelect, EventViewSimple
22 from Screens.InputBox import InputBox
23 from Screens.MessageBox import MessageBox
24 from Screens.MinuteInput import MinuteInput
25 from Screens.TimerSelection import TimerSelection
26 from Screens.PictureInPicture import PictureInPicture
27 from Screens.SubtitleDisplay import SubtitleDisplay
28 from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
29 from Screens.SleepTimerEdit import SleepTimerEdit
30 from Screens.TimeDateInput import TimeDateInput
31 from ServiceReference import ServiceReference
33 from Tools import Notifications
34 from Tools.Directories import SCOPE_HDD, resolveFilename
36 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
37 iPlayableService, eServiceReference, eDVBResourceManager, iFrontendInformation, eEPGCache
39 from time import time, localtime, strftime
40 from os import stat as os_stat
41 from bisect import insort
44 from Menu import MainMenu, mdom
48 self.dishDialog = self.session.instantiateDialog(Dish)
50 class InfoBarShowHide:
51 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
59 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
61 "toggleShow": self.toggleShow,
63 }, 1) # lower prio to make it possible to override ok and cancel..
65 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
67 iPlayableService.evStart: self.serviceStarted,
70 self.__state = self.STATE_SHOWN
73 self.hideTimer = eTimer()
74 self.hideTimer.callback.append(self.doTimerHide)
75 self.hideTimer.start(5000, True)
77 self.onShow.append(self.__onShow)
78 self.onHide.append(self.__onHide)
80 def serviceStarted(self):
82 if config.usage.show_infobar_on_zap.value:
86 self.__state = self.STATE_SHOWN
89 def startHideTimer(self):
90 if self.__state == self.STATE_SHOWN and not self.__locked:
91 idx = config.usage.infobar_timeout.index
93 self.hideTimer.start(idx*1000, True)
96 self.__state = self.STATE_HIDDEN
100 self.startHideTimer()
102 def doTimerHide(self):
103 self.hideTimer.stop()
104 if self.__state == self.STATE_SHOWN:
107 def toggleShow(self):
108 if self.__state == self.STATE_SHOWN:
110 self.hideTimer.stop()
111 elif self.__state == self.STATE_HIDDEN:
115 self.__locked = self.__locked + 1
118 self.hideTimer.stop()
120 def unlockShow(self):
121 self.__locked = self.__locked - 1
123 self.startHideTimer()
125 # def startShow(self):
126 # self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
127 # self.__state = self.STATE_SHOWN
129 # def startHide(self):
130 # self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
131 # self.__state = self.STATE_HIDDEN
133 class NumberZap(Screen):
140 self.close(int(self["number"].getText()))
142 def keyNumberGlobal(self, number):
143 self.Timer.start(3000, True) #reset timer
144 self.field = self.field + str(number)
145 self["number"].setText(self.field)
146 if len(self.field) >= 4:
149 def __init__(self, session, number):
150 Screen.__init__(self, session)
151 self.field = str(number)
153 self["channel"] = Label(_("Channel:"))
155 self["number"] = Label(self.field)
157 self["actions"] = NumberActionMap( [ "SetupActions" ],
161 "1": self.keyNumberGlobal,
162 "2": self.keyNumberGlobal,
163 "3": self.keyNumberGlobal,
164 "4": self.keyNumberGlobal,
165 "5": self.keyNumberGlobal,
166 "6": self.keyNumberGlobal,
167 "7": self.keyNumberGlobal,
168 "8": self.keyNumberGlobal,
169 "9": self.keyNumberGlobal,
170 "0": self.keyNumberGlobal
173 self.Timer = eTimer()
174 self.Timer.callback.append(self.keyOK)
175 self.Timer.start(3000, True)
177 class InfoBarNumberZap:
178 """ Handles an initial number for NumberZapping """
180 self["NumberActions"] = NumberActionMap( [ "NumberActions"],
182 "1": self.keyNumberGlobal,
183 "2": self.keyNumberGlobal,
184 "3": self.keyNumberGlobal,
185 "4": self.keyNumberGlobal,
186 "5": self.keyNumberGlobal,
187 "6": self.keyNumberGlobal,
188 "7": self.keyNumberGlobal,
189 "8": self.keyNumberGlobal,
190 "9": self.keyNumberGlobal,
191 "0": self.keyNumberGlobal,
194 def keyNumberGlobal(self, number):
195 # print "You pressed number " + str(number)
197 if isinstance(self, InfoBarPiP) and self.pipHandles0Action():
198 self.pipDoHandle0Action()
200 self.servicelist.recallPrevService()
202 if self.has_key("TimeshiftActions") and not self.timeshift_enabled:
203 self.session.openWithCallback(self.numberEntered, NumberZap, number)
205 def numberEntered(self, retval):
206 # print self.servicelist
208 self.zapToNumber(retval)
210 def searchNumberHelper(self, serviceHandler, num, bouquet):
211 servicelist = serviceHandler.list(bouquet)
212 if not servicelist is None:
214 serviceIterator = servicelist.getNext()
215 if not serviceIterator.valid(): #check end of list
217 playable = not (serviceIterator.flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
220 if not num: #found service with searched number ?
221 return serviceIterator, 0
224 def zapToNumber(self, number):
225 bouquet = self.servicelist.bouquet_root
227 serviceHandler = eServiceCenter.getInstance()
228 if not config.usage.multibouquet.value:
229 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
231 bouquetlist = serviceHandler.list(bouquet)
232 if not bouquetlist is None:
234 bouquet = bouquetlist.getNext()
235 if not bouquet.valid(): #check end of list
237 if bouquet.flags & eServiceReference.isDirectory:
238 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
239 if not service is None:
240 if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
241 self.servicelist.clearPath()
242 if self.servicelist.bouquet_root != bouquet:
243 self.servicelist.enterPath(self.servicelist.bouquet_root)
244 self.servicelist.enterPath(bouquet)
245 self.servicelist.setCurrentSelection(service) #select the service in servicelist
246 self.servicelist.zap()
248 config.misc.initialchannelselection = ConfigBoolean(default = True)
250 class InfoBarChannelSelection:
251 """ ChannelSelection - handles the channelSelection dialog and the initial
252 channelChange actions which open the channelSelection dialog """
255 self.servicelist = self.session.instantiateDialog(ChannelSelection)
257 if config.misc.initialchannelselection.value:
258 self.onShown.append(self.firstRun)
260 self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
262 "switchChannelUp": (self.switchChannelUp, _("open servicelist(up)")),
263 "switchChannelDown": (self.switchChannelDown, _("open servicelist(down)")),
264 "zapUp": (self.zapUp, _("previous channel")),
265 "zapDown": (self.zapDown, _("next channel")),
266 "historyBack": (self.historyBack, _("previous channel in history")),
267 "historyNext": (self.historyNext, _("next channel in history")),
268 "openServiceList": (self.openServiceList, _("open servicelist")),
271 def showTvChannelList(self, zap=False):
272 self.servicelist.setModeTv()
274 self.servicelist.zap()
275 self.session.execDialog(self.servicelist)
277 def showRadioChannelList(self, zap=False):
278 self.servicelist.setModeRadio()
280 self.servicelist.zap()
281 self.session.execDialog(self.servicelist)
284 self.onShown.remove(self.firstRun)
285 config.misc.initialchannelselection.value = False
286 config.misc.initialchannelselection.save()
287 self.switchChannelDown()
289 def historyBack(self):
290 self.servicelist.historyBack()
292 def historyNext(self):
293 self.servicelist.historyNext()
295 def switchChannelUp(self):
296 self.servicelist.moveUp()
297 self.session.execDialog(self.servicelist)
299 def switchChannelDown(self):
300 self.servicelist.moveDown()
301 self.session.execDialog(self.servicelist)
303 def openServiceList(self):
304 self.session.execDialog(self.servicelist)
307 if self.servicelist.inBouquet():
308 prev = self.servicelist.getCurrentSelection()
310 prev = prev.toString()
312 if config.usage.quickzap_bouquet_change.value:
313 if self.servicelist.atBegin():
314 self.servicelist.prevBouquet()
315 self.servicelist.moveUp()
316 cur = self.servicelist.getCurrentSelection()
317 if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
320 self.servicelist.moveUp()
321 self.servicelist.zap()
324 if self.servicelist.inBouquet():
325 prev = self.servicelist.getCurrentSelection()
327 prev = prev.toString()
329 if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd():
330 self.servicelist.nextBouquet()
332 self.servicelist.moveDown()
333 cur = self.servicelist.getCurrentSelection()
334 if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
337 self.servicelist.moveDown()
338 self.servicelist.zap()
341 """ Handles a menu action, to open the (main) menu """
343 self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions",
345 "mainMenu": (self.mainMenu, _("Enter main menu...")),
347 self.session.infobar = None
350 print "loading mainmenu XML..."
351 menu = mdom.childNodes[0]
352 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
354 self.session.infobar = self
355 # so we can access the currently active infobar from screens opened from within the mainmenu
356 # at the moment used from the SubserviceSelection
358 self.session.openWithCallback(self.mainMenuClosed, MainMenu, menu, menu.childNodes)
360 def mainMenuClosed(self, *val):
361 self.session.infobar = None
363 class InfoBarSimpleEventView:
364 """ Opens the Eventview for now/next """
366 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
368 "showEventInfo": (self.openEventView, _("show event details")),
371 def openEventView(self):
373 service = self.session.nav.getCurrentService()
374 ref = self.session.nav.getCurrentlyPlayingServiceReference()
375 info = service.info()
378 self.epglist.append(ptr)
381 self.epglist.append(ptr)
382 if len(self.epglist) > 0:
383 self.session.open(EventViewSimple, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
385 def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
386 if len(self.epglist) > 1:
387 tmp = self.epglist[0]
388 self.epglist[0]=self.epglist[1]
390 setEvent(self.epglist[0])
393 """ EPG - Opens an EPG list when the showEPGList action fires """
395 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
397 iPlayableService.evUpdatedEventInfo: self.__evEventInfoChanged,
400 self.is_now_next = False
402 self.bouquetSel = None
403 self.eventView = None
404 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
406 "showEventInfo": (self.openEventView, _("show EPG...")),
407 "showSingleServiceEPG": (self.openSingleServiceEPG, _("show single service EPG...")),
408 "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
411 def showEventInfoWhenNotVisible(self):
418 def zapToService(self, service):
419 if not service is None:
420 if self.servicelist.getRoot() != self.epg_bouquet: #already in correct bouquet?
421 self.servicelist.clearPath()
422 if self.servicelist.bouquet_root != self.epg_bouquet:
423 self.servicelist.enterPath(self.servicelist.bouquet_root)
424 self.servicelist.enterPath(self.epg_bouquet)
425 self.servicelist.setCurrentSelection(service) #select the service in servicelist
426 self.servicelist.zap()
428 def getBouquetServices(self, bouquet):
430 servicelist = eServiceCenter.getInstance().list(bouquet)
431 if not servicelist is None:
433 service = servicelist.getNext()
434 if not service.valid(): #check if end of list
436 if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker): #ignore non playable services
438 services.append(ServiceReference(service))
441 def openBouquetEPG(self, bouquet, withCallback=True):
442 services = self.getBouquetServices(bouquet)
444 self.epg_bouquet = bouquet
446 self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService, None, self.changeBouquetCB))
448 self.session.open(EPGSelection, services, self.zapToService, None, self.changeBouquetCB)
450 def changeBouquetCB(self, direction, epg):
453 self.bouquetSel.down()
456 bouquet = self.bouquetSel.getCurrent()
457 services = self.getBouquetServices(bouquet)
459 self.epg_bouquet = bouquet
460 epg.setServices(services)
462 def closed(self, ret=False):
463 closedScreen = self.dlg_stack.pop()
464 if self.bouquetSel and closedScreen == self.bouquetSel:
465 self.bouquetSel = None
466 elif self.eventView and closedScreen == self.eventView:
467 self.eventView = None
469 dlgs=len(self.dlg_stack)
471 self.dlg_stack[dlgs-1].close(dlgs > 1)
473 def openMultiServiceEPG(self, withCallback=True):
474 bouquets = self.servicelist.getBouquetList()
479 if cnt > 1: # show bouquet list
481 self.bouquetSel = self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
482 self.dlg_stack.append(self.bouquetSel)
484 self.bouquetSel = self.session.open(BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
486 self.openBouquetEPG(bouquets[0][1], withCallback)
488 def openSingleServiceEPG(self):
489 ref=self.session.nav.getCurrentlyPlayingServiceReference()
490 self.session.open(EPGSelection, ref)
492 def openSimilarList(self, eventid, refstr):
493 self.session.open(EPGSelection, refstr, None, eventid)
495 def getNowNext(self):
497 service = self.session.nav.getCurrentService()
498 info = service and service.info()
499 ptr = info and info.getEvent(0)
501 self.epglist.append(ptr)
502 ptr = info and info.getEvent(1)
504 self.epglist.append(ptr)
506 def __evEventInfoChanged(self):
507 if self.is_now_next and len(self.dlg_stack) == 1:
509 assert self.eventView
510 if len(self.epglist):
511 self.eventView.setEvent(self.epglist[0])
513 def openEventView(self):
514 ref = self.session.nav.getCurrentlyPlayingServiceReference()
516 if len(self.epglist) == 0:
517 self.is_now_next = False
518 epg = eEPGCache.getInstance()
519 ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
521 self.epglist.append(ptr)
522 ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
524 self.epglist.append(ptr)
526 self.is_now_next = True
527 if len(self.epglist) > 0:
528 self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
529 self.dlg_stack.append(self.eventView)
531 print "no epg for the service avail.. so we show multiepg instead of eventinfo"
532 self.openMultiServiceEPG(False)
534 def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
535 if len(self.epglist) > 1:
536 tmp = self.epglist[0]
537 self.epglist[0]=self.epglist[1]
539 setEvent(self.epglist[0])
542 """provides a snr/agc/ber display"""
544 self["FrontendStatus"] = ObsoleteSource(new_source = "session.FrontendStatus", removal_date = "2008-01")
547 """provides a current/next event info display"""
549 self["Event_Now"] = ObsoleteSource(new_source = "session.Event_Now", removal_date = "2008-01")
550 self["Event_Next"] = ObsoleteSource(new_source = "session.Event_Next", removal_date = "2008-01")
552 class InfoBarRdsDecoder:
553 """provides RDS and Rass support/display"""
555 self.rds_display = self.session.instantiateDialog(RdsInfoDisplay)
556 self.rass_interactive = None
558 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
560 iPlayableService.evEnd: self.__serviceStopped,
561 iPlayableService.evUpdatedRassSlidePic: self.RassSlidePicChanged
564 self["RdsActions"] = ActionMap(["InfobarRdsActions"],
566 "startRassInteractive": self.startRassInteractive
569 self["RdsActions"].setEnabled(False)
571 self.onLayoutFinish.append(self.rds_display.show)
572 self.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
574 def RassInteractivePossibilityChanged(self, state):
575 self["RdsActions"].setEnabled(state)
577 def RassSlidePicChanged(self):
578 if not self.rass_interactive:
579 service = self.session.nav.getCurrentService()
580 decoder = service and service.rdsDecoder()
582 decoder.showRassSlidePicture()
584 def __serviceStopped(self):
585 if self.rass_interactive is not None:
586 rass_interactive = self.rass_interactive
587 self.rass_interactive = None
588 rass_interactive.close()
590 def startRassInteractive(self):
591 self.rds_display.hide()
592 self.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
594 def RassInteractiveClosed(self, *val):
595 if self.rass_interactive is not None:
596 self.rass_interactive = None
597 self.RassSlidePicChanged()
598 self.rds_display.show()
600 class InfoBarServiceName:
602 self["CurrentService"] = ObsoleteSource(new_source = "session.CurrentService", removal_date = "2008-01")
605 """handles actions like seeking, pause"""
607 # ispause, isff, issm
608 SEEK_STATE_PLAY = (0, 0, 0, ">")
609 SEEK_STATE_PAUSE = (1, 0, 0, "||")
610 SEEK_STATE_FF_2X = (0, 2, 0, ">> 2x")
611 SEEK_STATE_FF_4X = (0, 4, 0, ">> 4x")
612 SEEK_STATE_FF_8X = (0, 8, 0, ">> 8x")
613 SEEK_STATE_FF_16X = (0, 16, 0, ">> 16x")
614 SEEK_STATE_FF_32X = (0, 32, 0, ">> 32x")
615 SEEK_STATE_FF_48X = (0, 48, 0, ">> 48x")
616 SEEK_STATE_FF_64X = (0, 64, 0, ">> 64x")
617 SEEK_STATE_FF_128X = (0, 128, 0, ">> 128x")
619 SEEK_STATE_BACK_8X = (0, -8, 0, "<< 8x")
620 SEEK_STATE_BACK_16X = (0, -16, 0, "<< 16x")
621 SEEK_STATE_BACK_32X = (0, -32, 0, "<< 32x")
622 SEEK_STATE_BACK_48X = (0, -48, 0, "<< 48x")
623 SEEK_STATE_BACK_64X = (0, -64, 0, "<< 64x")
624 SEEK_STATE_BACK_128X = (0, -128, 0, "<< 128x")
626 SEEK_STATE_SM_HALF = (0, 0, 2, "/2")
627 SEEK_STATE_SM_QUARTER = (0, 0, 4, "/4")
628 SEEK_STATE_SM_EIGHTH = (0, 0, 8, "/8")
630 SEEK_STATE_EOF = (1, 0, 0, "END")
632 def __init__(self, actionmap = "InfobarSeekActions"):
633 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
635 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
636 iPlayableService.evStart: self.__serviceStarted,
638 iPlayableService.evEOF: self.__evEOF,
639 iPlayableService.evSOF: self.__evSOF,
642 class InfoBarSeekActionMap(HelpableActionMap):
643 def __init__(self, screen, *args, **kwargs):
644 HelpableActionMap.__init__(self, screen, *args, **kwargs)
647 def action(self, contexts, action):
648 print "action:", action
649 if action[:5] == "seek:":
650 time = int(action[5:])
651 self.screen.seekRelative(time * 90000)
652 if config.usage.show_infobar_on_skip.value:
653 self.screen.showAfterSeek()
656 return HelpableActionMap.action(self, contexts, action)
658 self["SeekActions"] = InfoBarSeekActionMap(self, actionmap,
660 "playpauseService": self.playpauseService,
661 "pauseService": (self.pauseService, _("pause")),
662 "unPauseService": (self.unPauseService, _("continue")),
664 "seekFwd": (self.seekFwd, _("skip forward")),
665 "seekFwdManual": (self.seekFwdManual, _("skip forward (enter time)")),
666 "seekBack": (self.seekBack, _("skip backward")),
667 "seekBackManual": (self.seekBackManual, _("skip backward (enter time)")),
669 "seekFwdDef": (self.seekFwdDef, _("skip forward (self defined)")),
670 "seekBackDef": (self.seekBackDef, _("skip backward (self defined)"))
672 # give them a little more priority to win over color buttons
674 self["SeekActions"].setEnabled(False)
676 self.seekstate = self.SEEK_STATE_PLAY
678 self.seek_flag = True
680 self.onPlayStateChanged = [ ]
682 self.lockedBecauseOfSkipping = False
684 self.__seekableStatusChanged()
686 def showAfterSeek(self):
687 if isinstance(self, InfoBarShowHide):
697 service = self.session.nav.getCurrentService()
701 seek = service.seek()
703 if seek is None or not seek.isCurrentlySeekable():
708 def isSeekable(self):
709 if self.getSeek() is None:
713 def __seekableStatusChanged(self):
714 print "seekable status changed!"
715 if not self.isSeekable():
716 self["SeekActions"].setEnabled(False)
717 print "not seekable, return to play"
718 self.setSeekState(self.SEEK_STATE_PLAY)
720 self["SeekActions"].setEnabled(True)
723 def __serviceStarted(self):
724 self.seekstate = self.SEEK_STATE_PLAY
725 self.__seekableStatusChanged()
727 def setSeekState(self, state):
728 service = self.session.nav.getCurrentService()
733 if not self.isSeekable():
734 if state not in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
735 state = self.SEEK_STATE_PLAY
737 pauseable = service.pause()
739 if pauseable is None:
740 print "not pauseable."
741 state = self.SEEK_STATE_PLAY
743 oldstate = self.seekstate
744 self.seekstate = state
747 if oldstate[i] != self.seekstate[i]:
748 (self.session.nav.pause, pauseable.setFastForward, pauseable.setSlowMotion)[i](self.seekstate[i])
750 for c in self.onPlayStateChanged:
753 self.checkSkipShowHideLock()
757 def playpauseService(self):
758 if self.seekstate != self.SEEK_STATE_PLAY:
759 self.unPauseService()
763 def pauseService(self):
764 if self.seekstate == self.SEEK_STATE_PAUSE:
765 print "pause, but in fact unpause"
766 self.unPauseService()
768 if self.seekstate == self.SEEK_STATE_PLAY:
769 print "yes, playing."
771 print "no", self.seekstate
773 self.setSeekState(self.SEEK_STATE_PAUSE);
775 def unPauseService(self):
777 if self.seekstate == self.SEEK_STATE_PLAY:
779 self.setSeekState(self.SEEK_STATE_PLAY)
781 def doSeek(self, seektime):
782 print "doseek", seektime
783 service = self.session.nav.getCurrentService()
787 seekable = self.getSeek()
791 seekable.seekTo(90 * seektime)
795 self.SEEK_STATE_PLAY: self.SEEK_STATE_FF_2X,
796 self.SEEK_STATE_PAUSE: self.SEEK_STATE_SM_EIGHTH,
797 self.SEEK_STATE_FF_2X: self.SEEK_STATE_FF_4X,
798 self.SEEK_STATE_FF_4X: self.SEEK_STATE_FF_8X,
799 self.SEEK_STATE_FF_8X: self.SEEK_STATE_FF_16X,
800 self.SEEK_STATE_FF_16X: self.SEEK_STATE_FF_32X,
801 self.SEEK_STATE_FF_32X: self.SEEK_STATE_FF_48X,
802 self.SEEK_STATE_FF_48X: self.SEEK_STATE_FF_64X,
803 self.SEEK_STATE_FF_64X: self.SEEK_STATE_FF_128X,
804 self.SEEK_STATE_FF_128X: self.SEEK_STATE_FF_128X,
805 self.SEEK_STATE_BACK_8X: self.SEEK_STATE_PLAY,
806 self.SEEK_STATE_BACK_16X: self.SEEK_STATE_BACK_8X,
807 self.SEEK_STATE_BACK_32X: self.SEEK_STATE_BACK_16X,
808 self.SEEK_STATE_BACK_48X: self.SEEK_STATE_BACK_32X,
809 self.SEEK_STATE_BACK_64X: self.SEEK_STATE_BACK_48X,
810 self.SEEK_STATE_BACK_128X: self.SEEK_STATE_BACK_64X,
811 self.SEEK_STATE_SM_HALF: self.SEEK_STATE_SM_HALF,
812 self.SEEK_STATE_SM_QUARTER: self.SEEK_STATE_SM_HALF,
813 self.SEEK_STATE_SM_EIGHTH: self.SEEK_STATE_SM_QUARTER,
814 self.SEEK_STATE_EOF: self.SEEK_STATE_EOF,
816 self.setSeekState(lookup[self.seekstate])
820 self.SEEK_STATE_PLAY: self.SEEK_STATE_BACK_8X,
821 self.SEEK_STATE_PAUSE: self.SEEK_STATE_PAUSE,
822 self.SEEK_STATE_FF_2X: self.SEEK_STATE_PLAY,
823 self.SEEK_STATE_FF_4X: self.SEEK_STATE_FF_2X,
824 self.SEEK_STATE_FF_8X: self.SEEK_STATE_FF_4X,
825 self.SEEK_STATE_FF_16X: self.SEEK_STATE_FF_8X,
826 self.SEEK_STATE_FF_32X: self.SEEK_STATE_FF_16X,
827 self.SEEK_STATE_FF_48X: self.SEEK_STATE_FF_32X,
828 self.SEEK_STATE_FF_64X: self.SEEK_STATE_FF_48X,
829 self.SEEK_STATE_FF_128X: self.SEEK_STATE_FF_64X,
830 self.SEEK_STATE_BACK_8X: self.SEEK_STATE_BACK_16X,
831 self.SEEK_STATE_BACK_16X: self.SEEK_STATE_BACK_32X,
832 self.SEEK_STATE_BACK_32X: self.SEEK_STATE_BACK_48X,
833 self.SEEK_STATE_BACK_48X: self.SEEK_STATE_BACK_64X,
834 self.SEEK_STATE_BACK_64X: self.SEEK_STATE_BACK_128X,
835 self.SEEK_STATE_BACK_128X: self.SEEK_STATE_BACK_128X,
836 self.SEEK_STATE_SM_HALF: self.SEEK_STATE_SM_QUARTER,
837 self.SEEK_STATE_SM_QUARTER: self.SEEK_STATE_SM_EIGHTH,
838 self.SEEK_STATE_SM_EIGHTH: self.SEEK_STATE_PAUSE,
839 self.SEEK_STATE_EOF: self.SEEK_STATE_BACK_8X,
841 self.setSeekState(lookup[self.seekstate])
843 if self.seekstate == self.SEEK_STATE_PAUSE:
844 seekable = self.getSeek()
845 if seekable is not None:
846 seekable.seekRelative(-1, 3)
848 def seekFwdDef(self):
849 self.seek_flag = False
850 seconds = config.usage.self_defined_seek.value
851 print "Seek", seconds, "seconds self defined forward"
852 seekable = self.getSeek()
853 if seekable is not None:
854 seekable.seekRelative(1, seconds * 90000)
856 def seekBackDef(self):
857 self.seek_flag = False
858 seconds = config.usage.self_defined_seek.value
859 print "Seek", seconds, "seconds self defined backward"
860 seekable = self.getSeek()
861 if seekable is not None:
862 seekable.seekRelative(1, 0 - seconds * 90000)
864 def seekFwdManual(self):
865 self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
867 def fwdSeekTo(self, minutes):
868 print "Seek", minutes, "minutes forward"
870 seekable = self.getSeek()
871 if seekable is not None:
872 seekable.seekRelative(1, minutes * 60 * 90000)
874 def seekBackManual(self):
875 self.session.openWithCallback(self.rwdSeekTo, MinuteInput)
877 def rwdSeekTo(self, minutes):
879 self.fwdSeekTo(0 - minutes)
881 def checkSkipShowHideLock(self):
882 wantlock = self.seekstate != self.SEEK_STATE_PLAY
884 if config.usage.show_infobar_on_skip.value:
885 if self.lockedBecauseOfSkipping and not wantlock:
887 self.lockedBecauseOfSkipping = False
889 if wantlock and not self.lockedBecauseOfSkipping:
891 self.lockedBecauseOfSkipping = True
894 if self.seekstate == self.SEEK_STATE_EOF:
896 if self.seekstate[1] < 0: # SEEK_STATE_BACK_*X
897 print "end of stream while seeking back, ignoring."
900 # if we are seeking, we try to end up ~1s before the end, and pause there.
901 if not self.seekstate in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
902 self.setSeekState(self.SEEK_STATE_EOF)
903 self.seekRelativeToEnd(-90000)
905 self.setSeekState(self.SEEK_STATE_EOF)
908 self.setSeekState(self.SEEK_STATE_PLAY)
911 def seekRelative(self, diff):
912 if self.seek_flag == True:
913 seekable = self.getSeek()
914 if seekable is not None:
915 print "seekRelative: res:", seekable.seekRelative(1, diff)
919 self.seek_flag = True
921 def seekRelativeToEnd(self, diff):
922 assert diff <= 0, "diff is expected to be negative!"
924 # might sound like an evil hack, but:
925 # if we seekRelativeToEnd(0), we expect to be at the end, which is what we want,
926 # and we don't get that by passing 0 here (it would seek to begin).
930 # relative-to-end seeking is implemented as absolutes seeks with negative time
931 self.seekAbsolute(diff)
933 def seekAbsolute(self, abs):
934 seekable = self.getSeek()
935 if seekable is not None:
938 from Screens.PVRState import PVRState, TimeshiftState
940 class InfoBarPVRState:
941 def __init__(self, screen=PVRState):
942 self.onPlayStateChanged.append(self.__playStateChanged)
943 self.pvrStateDialog = self.session.instantiateDialog(screen)
944 self.onShow.append(self._mayShow)
945 self.onHide.append(self.pvrStateDialog.hide)
948 if self.execing and self.seekstate != self.SEEK_STATE_PLAY:
949 self.pvrStateDialog.show()
951 def __playStateChanged(self, state):
952 playstateString = state[3]
953 self.pvrStateDialog["state"].setText(playstateString)
956 class InfoBarTimeshiftState(InfoBarPVRState):
958 InfoBarPVRState.__init__(self, screen=TimeshiftState)
961 if self.execing and self.timeshift_enabled:
962 self.pvrStateDialog.show()
964 class InfoBarShowMovies:
966 # i don't really like this class.
967 # it calls a not further specified "movie list" on up/down/movieList,
968 # so this is not more than an action map
970 self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions",
972 "movieList": (self.showMovies, _("movie list")),
973 "up": (self.showMovies, _("movie list")),
974 "down": (self.showMovies, _("movie list"))
977 # InfoBarTimeshift requires InfoBarSeek, instantiated BEFORE!
981 # Timeshift works the following way:
982 # demux0 demux1 "TimeshiftActions" "TimeshiftActivateActions" "SeekActions"
983 # - normal playback TUNER unused PLAY enable disable disable
984 # - user presses "yellow" button. FILE record PAUSE enable disable enable
985 # - user presess pause again FILE record PLAY enable disable enable
986 # - user fast forwards FILE record FF enable disable enable
987 # - end of timeshift buffer reached TUNER record PLAY enable enable disable
988 # - user backwards FILE record BACK # !! enable disable enable
992 # - when a service is playing, pressing the "timeshiftStart" button ("yellow") enables recording ("enables timeshift"),
993 # freezes the picture (to indicate timeshift), sets timeshiftMode ("activates timeshift")
994 # now, the service becomes seekable, so "SeekActions" are enabled, "TimeshiftEnableActions" are disabled.
995 # - the user can now PVR around
996 # - if it hits the end, the service goes into live mode ("deactivates timeshift", it's of course still "enabled")
997 # the service looses it's "seekable" state. It can still be paused, but just to activate timeshift right
999 # the seek actions will be disabled, but the timeshiftActivateActions will be enabled
1000 # - if the user rewinds, or press pause, timeshift will be activated again
1002 # note that a timeshift can be enabled ("recording") and
1003 # activated (currently time-shifting).
1005 class InfoBarTimeshift:
1007 self["TimeshiftActions"] = HelpableActionMap(self, "InfobarTimeshiftActions",
1009 "timeshiftStart": (self.startTimeshift, _("start timeshift")), # the "yellow key"
1010 "timeshiftStop": (self.stopTimeshift, _("stop timeshift")) # currently undefined :), probably 'TV'
1012 self["TimeshiftActivateActions"] = ActionMap(["InfobarTimeshiftActivateActions"],
1014 "timeshiftActivateEnd": self.activateTimeshiftEnd, # something like "rewind key"
1015 "timeshiftActivateEndAndPause": self.activateTimeshiftEndAndPause # something like "pause key"
1016 }, prio=-1) # priority over record
1018 self.timeshift_enabled = 0
1019 self.timeshift_state = 0
1020 self.ts_rewind_timer = eTimer()
1021 self.ts_rewind_timer.callback.append(self.rewindService)
1023 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1025 iPlayableService.evStart: self.__serviceStarted,
1026 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged
1029 def getTimeshift(self):
1030 service = self.session.nav.getCurrentService()
1031 return service and service.timeshift()
1033 def startTimeshift(self):
1034 print "enable timeshift"
1035 ts = self.getTimeshift()
1037 self.session.open(MessageBox, _("Timeshift not possible!"), MessageBox.TYPE_ERROR)
1038 print "no ts interface"
1041 if self.timeshift_enabled:
1042 print "hu, timeshift already enabled?"
1044 if not ts.startTimeshift():
1045 self.timeshift_enabled = 1
1047 # we remove the "relative time" for now.
1048 #self.pvrStateDialog["timeshift"].setRelative(time.time())
1051 #self.setSeekState(self.SEEK_STATE_PAUSE)
1052 self.activateTimeshiftEnd(False)
1054 # enable the "TimeshiftEnableActions", which will override
1055 # the startTimeshift actions
1056 self.__seekableStatusChanged()
1058 print "timeshift failed"
1060 def stopTimeshift(self):
1061 if not self.timeshift_enabled:
1063 print "disable timeshift"
1064 ts = self.getTimeshift()
1067 self.session.openWithCallback(self.stopTimeshiftConfirmed, MessageBox, _("Stop Timeshift?"), MessageBox.TYPE_YESNO)
1069 def stopTimeshiftConfirmed(self, confirmed):
1073 ts = self.getTimeshift()
1078 self.timeshift_enabled = 0
1081 self.__seekableStatusChanged()
1083 # activates timeshift, and seeks to (almost) the end
1084 def activateTimeshiftEnd(self, back = True):
1085 ts = self.getTimeshift()
1086 print "activateTimeshiftEnd"
1091 if ts.isTimeshiftActive():
1092 print "!! activate timeshift called - but shouldn't this be a normal pause?"
1096 ts.activateTimeshift() # activate timeshift will automatically pause
1097 self.setSeekState(self.SEEK_STATE_PAUSE)
1098 self.seekRelativeToEnd(-90000) # seek approx. 1 sec before end
1101 self.ts_rewind_timer.start(200, 1)
1103 def rewindService(self):
1104 self.setSeekState(self.SEEK_STATE_BACK_16X)
1106 # same as activateTimeshiftEnd, but pauses afterwards.
1107 def activateTimeshiftEndAndPause(self):
1108 print "activateTimeshiftEndAndPause"
1109 #state = self.seekstate
1110 self.activateTimeshiftEnd(False)
1112 def __seekableStatusChanged(self):
1115 print "self.isSeekable", self.isSeekable()
1116 print "self.timeshift_enabled", self.timeshift_enabled
1118 # when this service is not seekable, but timeshift
1119 # is enabled, this means we can activate
1121 if not self.isSeekable() and self.timeshift_enabled:
1124 print "timeshift activate:", enabled
1125 self["TimeshiftActivateActions"].setEnabled(enabled)
1127 def __serviceStarted(self):
1128 self.timeshift_enabled = False
1129 self.__seekableStatusChanged()
1131 from Screens.PiPSetup import PiPSetup
1133 class InfoBarExtensions:
1134 EXTENSION_SINGLE = 0
1140 self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
1142 "extensions": (self.showExtensionSelection, _("view extensions...")),
1145 def addExtension(self, extension, key = None, type = EXTENSION_SINGLE):
1146 self.list.append((type, extension, key))
1148 def updateExtension(self, extension, key = None):
1149 self.extensionsList.append(extension)
1151 if self.extensionKeys.has_key(key):
1155 for x in self.availableKeys:
1156 if not self.extensionKeys.has_key(x):
1161 self.extensionKeys[key] = len(self.extensionsList) - 1
1163 def updateExtensions(self):
1164 self.extensionsList = []
1165 self.availableKeys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ]
1166 self.extensionKeys = {}
1168 if x[0] == self.EXTENSION_SINGLE:
1169 self.updateExtension(x[1], x[2])
1172 self.updateExtension(y[0], y[1])
1175 def showExtensionSelection(self):
1176 self.updateExtensions()
1177 extensionsList = self.extensionsList[:]
1180 for x in self.availableKeys:
1181 if self.extensionKeys.has_key(x):
1182 entry = self.extensionKeys[x]
1183 extension = self.extensionsList[entry]
1185 name = str(extension[0]())
1186 list.append((extension[0](), extension))
1188 extensionsList.remove(extension)
1190 extensionsList.remove(extension)
1191 for x in extensionsList:
1192 list.append((x[0](), x))
1193 keys += [""] * len(extensionsList)
1194 self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys)
1196 def extensionCallback(self, answer):
1197 if answer is not None:
1200 from Tools.BoundFunction import boundFunction
1202 # depends on InfoBarExtensions
1203 from Components.PluginComponent import plugins
1205 class InfoBarPlugins:
1207 self.addExtension(extension = self.getPluginList, type = InfoBarExtensions.EXTENSION_LIST)
1209 def getPluginName(self, name):
1212 def getPluginList(self):
1214 for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
1215 list.append(((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None))
1218 def runPlugin(self, plugin):
1219 plugin(session = self.session, servicelist = self.servicelist)
1221 # depends on InfoBarExtensions
1222 class InfoBarSleepTimer:
1224 self.addExtension((self.getSleepTimerName, self.showSleepTimerSetup, self.available), "1")
1226 def available(self):
1229 def getSleepTimerName(self):
1230 return _("Sleep Timer")
1232 def showSleepTimerSetup(self):
1233 self.session.open(SleepTimerEdit)
1235 # depends on InfoBarExtensions
1238 self.session.pipshown = False
1240 self.addExtension((self.getShowHideName, self.showPiP, self.available), "blue")
1241 self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
1242 self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
1244 def available(self):
1248 return self.session.pipshown
1250 def pipHandles0Action(self):
1251 return self.pipShown() and config.usage.pip_zero_button.value != "standard"
1253 def getShowHideName(self):
1254 if self.session.pipshown:
1255 return _("Disable Picture in Picture")
1257 return _("Activate Picture in Picture")
1259 def getSwapName(self):
1260 return _("Swap Services")
1262 def getMoveName(self):
1263 return _("Move Picture in Picture")
1266 if self.session.pipshown:
1267 del self.session.pip
1268 self.session.pipshown = False
1270 self.session.pip = self.session.instantiateDialog(PictureInPicture)
1271 self.session.pip.show()
1272 newservice = self.session.nav.getCurrentlyPlayingServiceReference()
1273 if self.session.pip.playService(newservice):
1274 self.session.pipshown = True
1275 self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
1277 self.session.pipshown = False
1278 del self.session.pip
1279 self.session.nav.playService(newservice)
1282 swapservice = self.session.nav.getCurrentlyPlayingServiceReference()
1283 if self.session.pip.servicePath:
1284 servicepath = self.servicelist.getCurrentServicePath()
1285 ref=servicepath[len(servicepath)-1]
1286 pipref=self.session.pip.getCurrentService()
1287 self.session.pip.playService(swapservice)
1288 self.servicelist.setCurrentServicePath(self.session.pip.servicePath)
1289 if pipref.toString() != ref.toString(): # is a subservice ?
1290 self.session.nav.stopService() # stop portal
1291 self.session.nav.playService(pipref) # start subservice
1292 self.session.pip.servicePath=servicepath
1295 self.session.open(PiPSetup, pip = self.session.pip)
1297 def pipDoHandle0Action(self):
1298 use = config.usage.pip_zero_button.value
1301 elif "swapstop" == use:
1307 from RecordTimer import parseEvent
1309 class InfoBarInstantRecord:
1310 """Instant Record - handles the instantRecord action in order to
1311 start/stop instant records"""
1313 self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
1315 "instantRecord": (self.instantRecord, _("Instant Record...")),
1318 #### DEPRECATED CODE ####
1319 self["BlinkingPoint"] = BlinkingPixmapConditional()
1320 self["BlinkingPoint"].setConnect(self.session.nav.RecordTimer.isRecording)
1321 self["BlinkingPoint"].deprecationInfo = (
1322 "session.RecordState source, Pixmap renderer and "
1323 "ConditionalShowHide/Blink Converter", "2008-02")
1324 #########################
1326 def stopCurrentRecording(self, entry = -1):
1327 if entry is not None and entry != -1:
1328 self.session.nav.RecordTimer.removeEntry(self.recording[entry])
1329 self.recording.remove(self.recording[entry])
1331 def startInstantRecording(self, limitEvent = False):
1332 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
1334 # try to get event info
1337 service = self.session.nav.getCurrentService()
1338 epg = eEPGCache.getInstance()
1339 event = epg.lookupEventTime(serviceref, -1, 0)
1341 info = service.info()
1342 ev = info.getEvent(0)
1348 end = time() + 3600 * 10
1349 name = "instant record"
1353 if event is not None:
1354 curEvent = parseEvent(event)
1356 description = curEvent[3]
1357 eventid = curEvent[4]
1362 self.session.open(MessageBox, _("No event info found, recording indefinitely."), MessageBox.TYPE_INFO)
1364 data = (begin, end, name, description, eventid)
1366 recording = self.session.nav.recordWithTimer(serviceref, *data)
1367 recording.dontSave = True
1368 self.recording.append(recording)
1370 #### DEPRECATED CODE ####
1371 self["BlinkingPoint"].setConnect(lambda: self.recording.isRunning())
1372 #########################
1374 def isInstantRecordRunning(self):
1375 print "self.recording:", self.recording
1376 if len(self.recording) > 0:
1377 for x in self.recording:
1382 def recordQuestionCallback(self, answer):
1383 print "pre:\n", self.recording
1385 if answer is None or answer[1] == "no":
1388 recording = self.recording[:]
1390 if not x in self.session.nav.RecordTimer.timer_list:
1391 self.recording.remove(x)
1392 elif x.dontSave and x.isRunning():
1393 list.append((x, False))
1395 if answer[1] == "changeduration":
1396 if len(self.recording) == 1:
1397 self.changeDuration(0)
1399 self.session.openWithCallback(self.changeDuration, TimerSelection, list)
1400 elif answer[1] == "changeendtime":
1401 if len(self.recording) == 1:
1404 self.session.openWithCallback(self.setEndtime, TimerSelection, list)
1405 elif answer[1] == "stop":
1406 if len(self.recording) == 1:
1407 self.stopCurrentRecording(0)
1409 self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
1410 elif answer[1] in ( "indefinitely" , "manualduration", "manualendtime", "event"):
1411 self.startInstantRecording(limitEvent = answer[1] in ("event", "manualendtime") or False)
1412 if answer[1] == "manualduration":
1413 self.changeDuration(len(self.recording)-1)
1414 elif answer[1] == "manualendtime":
1415 self.setEndtime(len(self.recording)-1)
1416 print "after:\n", self.recording
1418 def setEndtime(self, entry):
1419 if entry is not None:
1420 self.selectedEntry = entry
1421 self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end)
1422 dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime)
1423 dlg.setTitle(_("Please change recording endtime"))
1425 def TimeDateInputClosed(self, ret):
1428 localendtime = localtime(ret[1])
1429 print "stopping recording at", strftime("%c", localendtime)
1430 self.recording[self.selectedEntry].end = ret[1]
1431 self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
1433 def changeDuration(self, entry):
1434 if entry is not None:
1435 self.selectedEntry = entry
1436 self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5", maxSize=False, type=Input.NUMBER)
1438 def inputCallback(self, value):
1439 if value is not None:
1440 print "stopping recording after", int(value), "minutes."
1441 self.recording[self.selectedEntry].end = time() + 60 * int(value)
1442 self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
1444 def instantRecord(self):
1446 stat = os_stat(resolveFilename(SCOPE_HDD))
1448 self.session.open(MessageBox, _("No HDD found or HDD not initialized!"), MessageBox.TYPE_ERROR)
1451 if self.isInstantRecordRunning():
1452 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1453 title=_("A recording is currently running.\nWhat do you want to do?"), \
1454 list=[(_("stop recording"), "stop"), \
1455 (_("change recording (duration)"), "changeduration"), \
1456 (_("change recording (endtime)"), "changeendtime"), \
1457 (_("add recording (indefinitely)"), "indefinitely"), \
1458 (_("add recording (stop after current event)"), "event"), \
1459 (_("add recording (enter recording duration)"), "manualduration"), \
1460 (_("add recording (enter recording endtime)"), "manualendtime"), \
1461 (_("do nothing"), "no")])
1463 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1464 title=_("Start recording?"), \
1465 list=[(_("add recording (indefinitely)"), "indefinitely"), \
1466 (_("add recording (stop after current event)"), "event"), \
1467 (_("add recording (enter recording duration)"), "manualduration"), \
1468 (_("add recording (enter recording endtime)"), "manualendtime"), \
1469 (_("don't record"), "no")])
1471 from Tools.ISO639 import LanguageCodes
1473 class InfoBarAudioSelection:
1475 self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
1477 "audioSelection": (self.audioSelection, _("Audio Options...")),
1480 def audioSelection(self):
1481 service = self.session.nav.getCurrentService()
1482 audio = service and service.audioTracks()
1483 self.audioTracks = audio
1484 n = audio and audio.getNumberOfTracks() or 0
1485 keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
1488 self.audioChannel = service.audioChannel()
1491 i = audio.getTrackInfo(x)
1492 language = i.getLanguage()
1493 description = i.getDescription()
1495 if LanguageCodes.has_key(language):
1496 language = LanguageCodes[language][0]
1498 if len(description):
1499 description += " (" + language + ")"
1501 description = language
1503 tlist.append((description, x))
1505 selectedAudio = audio.getCurrentTrack()
1506 tlist.sort(key=lambda x: x[0])
1510 if x[1] != selectedAudio:
1515 tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
1516 self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys)
1518 del self.audioTracks
1520 def audioSelected(self, audio):
1521 if audio is not None:
1522 if isinstance(audio[1], str):
1523 if audio[1] == "mode":
1524 keys = ["red", "green", "yellow"]
1525 selection = self.audioChannel.getCurrentChannel()
1526 tlist = [(_("left"), 0), (_("stereo"), 1), (_("right"), 2)]
1527 self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys)
1529 del self.audioChannel
1530 if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]:
1531 self.audioTracks.selectTrack(audio[1])
1533 del self.audioChannel
1534 del self.audioTracks
1536 def modeSelected(self, mode):
1537 if mode is not None:
1538 self.audioChannel.selectChannel(mode[1])
1539 del self.audioChannel
1541 class InfoBarSubserviceSelection:
1543 self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",
1545 "subserviceSelection": (self.subserviceSelection, _("Subservice list...")),
1548 self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions",
1550 "nextSubservice": (self.nextSubservice, _("Switch to next subservice")),
1551 "prevSubservice": (self.prevSubservice, _("Switch to previous subservice"))
1553 self["SubserviceQuickzapAction"].setEnabled(False)
1555 self.session.nav.event.append(self.checkSubservicesAvail) # we like to get service events
1559 def checkSubservicesAvail(self, ev):
1560 if ev == iPlayableService.evUpdatedEventInfo:
1561 service = self.session.nav.getCurrentService()
1562 subservices = service and service.subServices()
1563 if not subservices or subservices.getNumberOfSubservices() == 0:
1564 self["SubserviceQuickzapAction"].setEnabled(False)
1566 def nextSubservice(self):
1567 self.changeSubservice(+1)
1569 def prevSubservice(self):
1570 self.changeSubservice(-1)
1572 def changeSubservice(self, direction):
1573 service = self.session.nav.getCurrentService()
1574 subservices = service and service.subServices()
1575 n = subservices and subservices.getNumberOfSubservices()
1578 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1580 if subservices.getSubservice(x).toString() == ref.toString():
1583 selection += direction
1588 newservice = subservices.getSubservice(selection)
1589 if newservice.valid():
1592 self.session.nav.playService(newservice)
1594 def subserviceSelection(self):
1595 service = self.session.nav.getCurrentService()
1596 subservices = service and service.subServices()
1597 self.bouquets = self.servicelist.getBouquetList()
1598 n = subservices and subservices.getNumberOfSubservices()
1601 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1604 i = subservices.getSubservice(x)
1605 if i.toString() == ref.toString():
1607 tlist.append((i.getName(), i))
1609 if self.bouquets and len(self.bouquets):
1610 keys = ["red", "green", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1611 if config.usage.multibouquet.value:
1612 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to bouquet"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1614 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to favourites"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1617 tlist = [(_("Quickzap"), "quickzap", service.subServices()), ("--", "")] + tlist
1618 keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1621 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys)
1623 def subserviceSelected(self, service):
1625 if not service is None:
1626 if isinstance(service[1], str):
1627 if service[1] == "quickzap":
1628 from Screens.SubservicesQuickzap import SubservicesQuickzap
1629 self.session.open(SubservicesQuickzap, service[2])
1631 self["SubserviceQuickzapAction"].setEnabled(True)
1632 self.session.nav.playService(service[1])
1634 def addSubserviceToBouquetCallback(self, service):
1635 if len(service) > 1 and isinstance(service[1], eServiceReference):
1636 self.selectedSubservice = service
1637 if self.bouquets is None:
1640 cnt = len(self.bouquets)
1641 if cnt > 1: # show bouquet list
1642 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, self.bouquets, self.addSubserviceToBouquet)
1643 elif cnt == 1: # add to only one existing bouquet
1644 self.addSubserviceToBouquet(self.bouquets[0][1])
1645 self.session.open(MessageBox, _("Service has been added to the favourites."), MessageBox.TYPE_INFO)
1647 def bouquetSelClosed(self, confirmed):
1649 del self.selectedSubservice
1651 self.session.open(MessageBox, _("Service has been added to the selected bouquet."), MessageBox.TYPE_INFO)
1653 def addSubserviceToBouquet(self, dest):
1654 self.servicelist.addServiceToBouquet(dest, self.selectedSubservice[1])
1656 self.bsel.close(True)
1658 del self.selectedSubservice
1660 class InfoBarAdditionalInfo:
1663 self["RecordingPossible"] = Boolean(fixed=harddiskmanager.HDDCount() > 0)
1664 self["TimeshiftPossible"] = self["RecordingPossible"]
1665 self["ExtensionsAvailable"] = Boolean(fixed=1)
1667 ######### DEPRECATED CODE ##########
1668 self["NimA"] = Pixmap()
1669 self["NimA"].deprecationInfo = (
1670 "session.TunerInfo source, Pixmap renderer, TunerInfo/UseMask Converter"
1671 ", ValueBitTest(1) Converter and ConditionalShowHide Converter", "2008-02")
1672 self["NimB"] = Pixmap()
1673 self["NimB"].deprecationInfo = (
1674 "session.TunerInfo source, Pixmap renderer, TunerInfo/UseMask Converter"
1675 ", ValueBitTest(2) Converter and ConditionalShowHide Converter", "2008-02")
1676 self["NimA_Active"] = Pixmap()
1677 self["NimA_Active"].deprecationInfo = (
1678 "session.FrontendInfo source, Pixmap renderer, FrontendInfo/NUMBER Converter"
1679 ", ValueRange(1,1) Converter and ConditionalShowHide Converter", "2008-02")
1680 self["NimB_Active"] = Pixmap()
1681 self["NimB_Active"].deprecationInfo = (
1682 "session.FrontendInfo source, Pixmap renderer, FrontendInfo/NUMBER Converter"
1683 ", ValueRange(1,1) Converter and ConditionalShowHide Converter", "2008-02")
1685 res_mgr = eDVBResourceManager.getInstance()
1687 res_mgr.frontendUseMaskChanged.get().append(self.tunerUseMaskChanged)
1689 self.session.nav.event.append(self.gotServiceEvent) # we like to get service events
1691 def tunerUseMaskChanged(self, mask):
1693 self["NimA_Active"].show()
1695 self["NimA_Active"].hide()
1697 self["NimB_Active"].show()
1699 self["NimB_Active"].hide()
1701 def checkTunerState(self, service):
1702 info = service and service.frontendInfo()
1703 feNumber = info and info.getFrontendInfo(iFrontendInformation.frontendNumber)
1704 if feNumber is None:
1714 def gotServiceEvent(self, ev):
1715 service = self.session.nav.getCurrentService()
1716 if ev == iPlayableService.evUpdatedInfo or ev == iPlayableService.evEnd:
1717 self.checkTunerState(service)
1718 ####################################
1720 class InfoBarNotifications:
1722 self.onExecBegin.append(self.checkNotifications)
1723 Notifications.notificationAdded.append(self.checkNotificationsIfExecing)
1724 self.onClose.append(self.__removeNotification)
1726 def __removeNotification(self):
1727 Notifications.notificationAdded.remove(self.checkNotificationsIfExecing)
1729 def checkNotificationsIfExecing(self):
1731 self.checkNotifications()
1733 def checkNotifications(self):
1734 if len(Notifications.notifications):
1735 n = Notifications.notifications[0]
1737 Notifications.notifications = Notifications.notifications[1:]
1740 if n[3].has_key("onSessionOpenCallback"):
1741 n[3]["onSessionOpenCallback"]()
1742 del n[3]["onSessionOpenCallback"]
1745 dlg = self.session.openWithCallback(cb, n[1], *n[2], **n[3])
1747 dlg = self.session.open(n[1], *n[2], **n[3])
1749 # remember that this notification is currently active
1751 Notifications.current_notifications.append(d)
1752 dlg.onClose.append(boundFunction(self.__notificationClosed, d))
1754 def __notificationClosed(self, d):
1755 Notifications.current_notifications.remove(d)
1757 class InfoBarServiceNotifications:
1759 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1761 iPlayableService.evEnd: self.serviceHasEnded
1764 def serviceHasEnded(self):
1765 print "service end!"
1768 self.setSeekState(self.SEEK_STATE_PLAY)
1772 class InfoBarCueSheetSupport:
1778 ENABLE_RESUME_SUPPORT = False
1780 def __init__(self, actionmap = "InfobarCueSheetActions"):
1781 self["CueSheetActions"] = HelpableActionMap(self, actionmap,
1783 "jumpPreviousMark": (self.jumpPreviousMark, _("jump to previous marked position")),
1784 "jumpNextMark": (self.jumpNextMark, _("jump to next marked position")),
1785 "toggleMark": (self.toggleMark, _("toggle a cut mark at the current position"))
1789 self.is_closing = False
1790 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1792 iPlayableService.evStart: self.__serviceStarted,
1795 def __serviceStarted(self):
1798 print "new service started! trying to download cuts!"
1799 self.downloadCuesheet()
1801 if self.ENABLE_RESUME_SUPPORT:
1804 for (pts, what) in self.cut_list:
1805 if what == self.CUT_TYPE_LAST:
1808 if last is not None:
1809 self.resume_point = last
1810 Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Do you want to resume this playback?"), timeout=10)
1812 def playLastCB(self, answer):
1814 seekable = self.__getSeekable()
1815 if seekable is not None:
1816 seekable.seekTo(self.resume_point)
1817 self.hideAfterResume()
1819 def hideAfterResume(self):
1820 if isinstance(self, InfoBarShowHide):
1823 def __getSeekable(self):
1824 service = self.session.nav.getCurrentService()
1827 return service.seek()
1829 def cueGetCurrentPosition(self):
1830 seek = self.__getSeekable()
1833 r = seek.getPlayPosition()
1838 def jumpPreviousNextMark(self, cmp, alternative=None):
1839 current_pos = self.cueGetCurrentPosition()
1840 if current_pos is None:
1842 mark = self.getNearestCutPoint(current_pos, cmp=cmp)
1843 if mark is not None:
1845 elif alternative is not None:
1850 seekable = self.__getSeekable()
1851 if seekable is not None:
1852 seekable.seekTo(pts)
1854 def jumpPreviousMark(self):
1855 # we add 2 seconds, so if the play position is <2s after
1856 # the mark, the mark before will be used
1857 self.jumpPreviousNextMark(lambda x: -x-5*90000, alternative=0)
1859 def jumpNextMark(self):
1860 self.jumpPreviousNextMark(lambda x: x)
1862 def getNearestCutPoint(self, pts, cmp=abs):
1865 for cp in self.cut_list:
1866 diff = cmp(cp[0] - pts)
1867 if cp[1] == self.CUT_TYPE_MARK and diff >= 0 and (nearest is None or cmp(nearest[0] - pts) > diff):
1871 def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000, onlyreturn=False):
1872 current_pos = self.cueGetCurrentPosition()
1873 if current_pos is None:
1874 print "not seekable"
1877 nearest_cutpoint = self.getNearestCutPoint(current_pos)
1879 if nearest_cutpoint is not None and abs(nearest_cutpoint[0] - current_pos) < tolerance:
1881 return nearest_cutpoint
1883 self.removeMark(nearest_cutpoint)
1884 elif not onlyremove and not onlyreturn:
1885 self.addMark((current_pos, self.CUT_TYPE_MARK))
1890 def addMark(self, point):
1891 insort(self.cut_list, point)
1892 self.uploadCuesheet()
1893 self.showAfterCuesheetOperation()
1895 def removeMark(self, point):
1896 self.cut_list.remove(point)
1897 self.uploadCuesheet()
1898 self.showAfterCuesheetOperation()
1900 def showAfterCuesheetOperation(self):
1901 if isinstance(self, InfoBarShowHide):
1904 def __getCuesheet(self):
1905 service = self.session.nav.getCurrentService()
1908 return service.cueSheet()
1910 def uploadCuesheet(self):
1911 cue = self.__getCuesheet()
1914 print "upload failed, no cuesheet interface"
1916 cue.setCutList(self.cut_list)
1918 def downloadCuesheet(self):
1919 cue = self.__getCuesheet()
1922 print "download failed, no cuesheet interface"
1925 self.cut_list = cue.getCutList()
1927 class InfoBarSummary(Screen):
1929 <screen position="0,0" size="132,64">
1930 <widget source="global.CurrentTime" render="Label" position="62,46" size="82,18" font="Regular;16" >
1931 <convert type="ClockToText">WithSeconds</convert>
1933 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="82,18" zPosition="1" >
1934 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
1935 <convert type="ConditionalShowHide">Blink</convert>
1937 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
1938 <convert type="ServiceName">Name</convert>
1940 <widget source="session.Event_Now" render="Progress" position="6,46" size="46,18" borderWidth="1" >
1941 <convert type="EventTime">Progress</convert>
1945 # for picon: (path="piconlcd" will use LCD picons)
1946 # <widget source="session.CurrentService" render="Picon" position="6,0" size="120,64" path="piconlcd" >
1947 # <convert type="ServiceName">Reference</convert>
1950 def __init__(self, session, parent):
1951 Screen.__init__(self, session, parent = parent)
1953 class InfoBarSummarySupport:
1957 def createSummary(self):
1958 return InfoBarSummary
1960 class InfoBarMoviePlayerSummary(Screen):
1962 <screen position="0,0" size="132,64">
1963 <widget source="global.CurrentTime" render="Label" position="62,46" size="64,18" font="Regular;16" halign="right" >
1964 <convert type="ClockToText">WithSeconds</convert>
1966 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="64,18" zPosition="1" >
1967 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
1968 <convert type="ConditionalShowHide">Blink</convert>
1970 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
1971 <convert type="ServiceName">Name</convert>
1973 <widget source="session.CurrentService" render="Progress" position="6,46" size="56,18" borderWidth="1" >
1974 <convert type="ServicePosition">Position</convert>
1978 def __init__(self, session, parent):
1979 Screen.__init__(self, session)
1981 class InfoBarMoviePlayerSummarySupport:
1985 def createSummary(self):
1986 return InfoBarMoviePlayerSummary
1988 class InfoBarTeletextPlugin:
1990 self.teletext_plugin = None
1992 for p in plugins.getPlugins(PluginDescriptor.WHERE_TELETEXT):
1993 self.teletext_plugin = p
1995 if self.teletext_plugin is not None:
1996 self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions",
1998 "startTeletext": (self.startTeletext, _("View teletext..."))
2001 print "no teletext plugin found!"
2003 def startTeletext(self):
2004 self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService())
2006 class InfoBarSubtitleSupport(object):
2008 object.__init__(self)
2009 self.subtitle_window = self.session.instantiateDialog(SubtitleDisplay)
2010 self.__subtitles_enabled = False
2012 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2014 iPlayableService.evEnd: self.__serviceStopped,
2015 iPlayableService.evUpdatedInfo: self.__updatedInfo
2017 self.cached_subtitle_checked = False
2018 self.__selected_subtitle = None
2020 def __serviceStopped(self):
2021 self.subtitle_window.hide()
2022 self.__subtitles_enabled = False
2023 self.cached_subtitle_checked = False
2025 def __updatedInfo(self):
2026 if not self.cached_subtitle_checked:
2027 subtitle = self.getCurrentServiceSubtitle()
2028 self.cached_subtitle_checked = True
2029 self.__selected_subtitle = subtitle and subtitle.getCachedSubtitle()
2030 if self.__selected_subtitle:
2031 subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
2032 self.subtitle_window.show()
2033 self.__subtitles_enabled = True
2035 def getCurrentServiceSubtitle(self):
2036 service = self.session.nav.getCurrentService()
2037 return service and service.subtitle()
2039 def setSubtitlesEnable(self, enable=True):
2040 subtitle = self.getCurrentServiceSubtitle()
2041 if enable and self.__selected_subtitle is not None:
2042 if subtitle and not self.__subtitles_enabled:
2043 subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
2044 self.subtitle_window.show()
2045 self.__subtitles_enabled = True
2048 subtitle.disableSubtitles(self.subtitle_window.instance)
2049 self.__subtitles_enabled = False
2050 self.subtitle_window.hide()
2052 def setSelectedSubtitle(self, subtitle):
2053 self.__selected_subtitle = subtitle
2055 subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable)
2056 selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle)
2058 class InfoBarServiceErrorPopupSupport:
2060 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2062 iPlayableService.evTuneFailed: self.__tuneFailed,
2063 iPlayableService.evStart: self.__serviceStarted
2065 self.__serviceStarted()
2067 def __serviceStarted(self):
2068 self.last_error = None
2069 Notifications.RemovePopup(id = "ZapError")
2071 def __tuneFailed(self):
2072 service = self.session.nav.getCurrentService()
2073 info = service and service.info()
2074 error = info and info.getInfo(iServiceInformation.sDVBState)
2076 if error == self.last_error:
2079 self.last_error = error
2082 eDVBServicePMTHandler.eventNoResources: _("No free tuner!"),
2083 eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"),
2084 eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"),
2085 eDVBServicePMTHandler.eventNoPATEntry: _("Service not found!\n(SID not found in PAT)"),
2086 eDVBServicePMTHandler.eventNoPMT: _("Service invalid!\n(Timeout reading PMT)"),
2087 eDVBServicePMTHandler.eventNewProgramInfo: None,
2088 eDVBServicePMTHandler.eventTuned: None,
2089 eDVBServicePMTHandler.eventSOF: None,
2090 eDVBServicePMTHandler.eventEOF: None,
2091 eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"),
2094 error = errors.get(error) #this returns None when the key not exist in the dict
2096 if error is not None:
2097 Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError")
2099 Notifications.RemovePopup(id = "ZapError")