1 from ChannelSelection import ChannelSelection, BouquetSelector
3 from Components.ActionMap import ActionMap, HelpableActionMap
4 from Components.ActionMap import NumberActionMap
5 from Components.Harddisk import harddiskmanager
6 from Components.Input import Input
7 from Components.Label import Label
8 from Components.PluginComponent import plugins
9 from Components.ServiceEventTracker import ServiceEventTracker
10 from Components.Sources.Boolean import Boolean
11 from Components.config import config, ConfigBoolean, ConfigClock
12 from Components.SystemInfo import SystemInfo
13 from Components.UsageConfig import preferredInstantRecordPath, defaultMoviePath
14 from EpgSelection import EPGSelection
15 from Plugins.Plugin import PluginDescriptor
17 from Screen import Screen
18 from Screens.ChoiceBox import ChoiceBox
19 from Screens.Dish import Dish
20 from Screens.EventView import EventViewEPGSelect, EventViewSimple
21 from Screens.InputBox import InputBox
22 from Screens.MessageBox import MessageBox
23 from Screens.MinuteInput import MinuteInput
24 from Screens.TimerSelection import TimerSelection
25 from Screens.PictureInPicture import PictureInPicture
26 from Screens.SubtitleDisplay import SubtitleDisplay
27 from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
28 from Screens.TimeDateInput import TimeDateInput
29 from Screens.UnhandledKey import UnhandledKey
30 from ServiceReference import ServiceReference
32 from Tools import Notifications
33 from Tools.Directories import fileExists
35 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
36 iPlayableService, eServiceReference, eEPGCache, eActionMap
38 from time import time, localtime, strftime
39 from os import stat as os_stat
40 from bisect import insort
42 from RecordTimer import RecordTimerEntry, RecordTimer
45 from Menu import MainMenu, mdom
49 self.dishDialog = self.session.instantiateDialog(Dish)
51 class InfoBarUnhandledKey:
53 self.unhandledKeyDialog = self.session.instantiateDialog(UnhandledKey)
54 self.hideUnhandledKeySymbolTimer = eTimer()
55 self.hideUnhandledKeySymbolTimer.callback.append(self.unhandledKeyDialog.hide)
56 self.checkUnusedTimer = eTimer()
57 self.checkUnusedTimer.callback.append(self.checkUnused)
58 self.onLayoutFinish.append(self.unhandledKeyDialog.hide)
59 eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.actionA) #highest prio
60 eActionMap.getInstance().bindAction('', 0x7FFFFFFF, self.actionB) #lowest prio
64 #this function is called on every keypress!
65 def actionA(self, key, flag):
67 if self.flags & (1<<1):
68 self.flags = self.uflags = 0
69 self.flags |= (1<<flag)
71 self.checkUnusedTimer.start(0, True)
74 #this function is only called when no other action has handled this key
75 def actionB(self, key, flag):
77 self.uflags |= (1<<flag)
79 def checkUnused(self):
80 if self.flags == self.uflags:
81 self.unhandledKeyDialog.show()
82 self.hideUnhandledKeySymbolTimer.start(2000, True)
84 class InfoBarShowHide:
85 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
93 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
95 "toggleShow": self.toggleShow,
97 }, 1) # lower prio to make it possible to override ok and cancel..
99 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
101 iPlayableService.evStart: self.serviceStarted,
104 self.__state = self.STATE_SHOWN
107 self.hideTimer = eTimer()
108 self.hideTimer.callback.append(self.doTimerHide)
109 self.hideTimer.start(5000, True)
111 self.onShow.append(self.__onShow)
112 self.onHide.append(self.__onHide)
114 def serviceStarted(self):
116 if config.usage.show_infobar_on_zap.value:
120 self.__state = self.STATE_SHOWN
121 self.startHideTimer()
123 def startHideTimer(self):
124 if self.__state == self.STATE_SHOWN and not self.__locked:
125 idx = config.usage.infobar_timeout.index
127 self.hideTimer.start(idx*1000, True)
130 self.__state = self.STATE_HIDDEN
134 self.startHideTimer()
136 def doTimerHide(self):
137 self.hideTimer.stop()
138 if self.__state == self.STATE_SHOWN:
141 def toggleShow(self):
142 if self.__state == self.STATE_SHOWN:
144 self.hideTimer.stop()
145 elif self.__state == self.STATE_HIDDEN:
149 self.__locked = self.__locked + 1
152 self.hideTimer.stop()
154 def unlockShow(self):
155 self.__locked = self.__locked - 1
157 self.startHideTimer()
159 # def startShow(self):
160 # self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
161 # self.__state = self.STATE_SHOWN
163 # def startHide(self):
164 # self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
165 # self.__state = self.STATE_HIDDEN
167 class NumberZap(Screen):
174 self.close(int(self["number"].getText()))
176 def keyNumberGlobal(self, number):
177 self.Timer.start(3000, True) #reset timer
178 self.field = self.field + str(number)
179 self["number"].setText(self.field)
180 if len(self.field) >= 4:
183 def __init__(self, session, number):
184 Screen.__init__(self, session)
185 self.field = str(number)
187 self["channel"] = Label(_("Channel:"))
189 self["number"] = Label(self.field)
191 self["actions"] = NumberActionMap( [ "SetupActions" ],
195 "1": self.keyNumberGlobal,
196 "2": self.keyNumberGlobal,
197 "3": self.keyNumberGlobal,
198 "4": self.keyNumberGlobal,
199 "5": self.keyNumberGlobal,
200 "6": self.keyNumberGlobal,
201 "7": self.keyNumberGlobal,
202 "8": self.keyNumberGlobal,
203 "9": self.keyNumberGlobal,
204 "0": self.keyNumberGlobal
207 self.Timer = eTimer()
208 self.Timer.callback.append(self.keyOK)
209 self.Timer.start(3000, True)
211 class InfoBarNumberZap:
212 """ Handles an initial number for NumberZapping """
214 self["NumberActions"] = NumberActionMap( [ "NumberActions"],
216 "1": self.keyNumberGlobal,
217 "2": self.keyNumberGlobal,
218 "3": self.keyNumberGlobal,
219 "4": self.keyNumberGlobal,
220 "5": self.keyNumberGlobal,
221 "6": self.keyNumberGlobal,
222 "7": self.keyNumberGlobal,
223 "8": self.keyNumberGlobal,
224 "9": self.keyNumberGlobal,
225 "0": self.keyNumberGlobal,
228 def keyNumberGlobal(self, number):
229 # print "You pressed number " + str(number)
231 if isinstance(self, InfoBarPiP) and self.pipHandles0Action():
232 self.pipDoHandle0Action()
234 self.servicelist.recallPrevService()
236 if self.has_key("TimeshiftActions") and not self.timeshift_enabled:
237 self.session.openWithCallback(self.numberEntered, NumberZap, number)
239 def numberEntered(self, retval):
240 # print self.servicelist
242 self.zapToNumber(retval)
244 def searchNumberHelper(self, serviceHandler, num, bouquet):
245 servicelist = serviceHandler.list(bouquet)
246 if not servicelist is None:
248 serviceIterator = servicelist.getNext()
249 if not serviceIterator.valid(): #check end of list
251 playable = not (serviceIterator.flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
254 if not num: #found service with searched number ?
255 return serviceIterator, 0
258 def zapToNumber(self, number):
259 bouquet = self.servicelist.bouquet_root
261 serviceHandler = eServiceCenter.getInstance()
262 if not config.usage.multibouquet.value:
263 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
265 bouquetlist = serviceHandler.list(bouquet)
266 if not bouquetlist is None:
268 bouquet = bouquetlist.getNext()
269 if not bouquet.valid(): #check end of list
271 if bouquet.flags & eServiceReference.isDirectory:
272 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
273 if not service is None:
274 if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
275 self.servicelist.clearPath()
276 if self.servicelist.bouquet_root != bouquet:
277 self.servicelist.enterPath(self.servicelist.bouquet_root)
278 self.servicelist.enterPath(bouquet)
279 self.servicelist.setCurrentSelection(service) #select the service in servicelist
280 self.servicelist.zap()
282 config.misc.initialchannelselection = ConfigBoolean(default = True)
284 class InfoBarChannelSelection:
285 """ ChannelSelection - handles the channelSelection dialog and the initial
286 channelChange actions which open the channelSelection dialog """
289 self.servicelist = self.session.instantiateDialog(ChannelSelection)
291 if config.misc.initialchannelselection.value:
292 self.onShown.append(self.firstRun)
294 self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
296 "switchChannelUp": (self.switchChannelUp, _("open servicelist(up)")),
297 "switchChannelDown": (self.switchChannelDown, _("open servicelist(down)")),
298 "zapUp": (self.zapUp, _("previous channel")),
299 "zapDown": (self.zapDown, _("next channel")),
300 "historyBack": (self.historyBack, _("previous channel in history")),
301 "historyNext": (self.historyNext, _("next channel in history")),
302 "openServiceList": (self.openServiceList, _("open servicelist")),
305 def showTvChannelList(self, zap=False):
306 self.servicelist.setModeTv()
308 self.servicelist.zap()
309 self.session.execDialog(self.servicelist)
311 def showRadioChannelList(self, zap=False):
312 self.servicelist.setModeRadio()
314 self.servicelist.zap()
315 self.session.execDialog(self.servicelist)
318 self.onShown.remove(self.firstRun)
319 config.misc.initialchannelselection.value = False
320 config.misc.initialchannelselection.save()
321 self.switchChannelDown()
323 def historyBack(self):
324 self.servicelist.historyBack()
326 def historyNext(self):
327 self.servicelist.historyNext()
329 def switchChannelUp(self):
330 self.servicelist.moveUp()
331 self.session.execDialog(self.servicelist)
333 def switchChannelDown(self):
334 self.servicelist.moveDown()
335 self.session.execDialog(self.servicelist)
337 def openServiceList(self):
338 self.session.execDialog(self.servicelist)
341 if self.servicelist.inBouquet():
342 prev = self.servicelist.getCurrentSelection()
344 prev = prev.toString()
346 if config.usage.quickzap_bouquet_change.value:
347 if self.servicelist.atBegin():
348 self.servicelist.prevBouquet()
349 self.servicelist.moveUp()
350 cur = self.servicelist.getCurrentSelection()
351 if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
354 self.servicelist.moveUp()
355 self.servicelist.zap()
358 if self.servicelist.inBouquet():
359 prev = self.servicelist.getCurrentSelection()
361 prev = prev.toString()
363 if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd():
364 self.servicelist.nextBouquet()
366 self.servicelist.moveDown()
367 cur = self.servicelist.getCurrentSelection()
368 if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
371 self.servicelist.moveDown()
372 self.servicelist.zap()
375 """ Handles a menu action, to open the (main) menu """
377 self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions",
379 "mainMenu": (self.mainMenu, _("Enter main menu...")),
381 self.session.infobar = None
384 print "loading mainmenu XML..."
385 menu = mdom.getroot()
386 assert menu.tag == "menu", "root element in menu must be 'menu'!"
388 self.session.infobar = self
389 # so we can access the currently active infobar from screens opened from within the mainmenu
390 # at the moment used from the SubserviceSelection
392 self.session.openWithCallback(self.mainMenuClosed, MainMenu, menu)
394 def mainMenuClosed(self, *val):
395 self.session.infobar = None
397 class InfoBarSimpleEventView:
398 """ Opens the Eventview for now/next """
400 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
402 "showEventInfo": (self.openEventView, _("show event details")),
403 "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
406 def showEventInfoWhenNotVisible(self):
413 def openEventView(self):
415 self.epglist = epglist
416 service = self.session.nav.getCurrentService()
417 ref = self.session.nav.getCurrentlyPlayingServiceReference()
418 info = service.info()
426 self.session.open(EventViewSimple, epglist[0], ServiceReference(ref), self.eventViewCallback)
428 def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
429 epglist = self.epglist
432 epglist[0] = epglist[1]
436 class SimpleServicelist:
437 def __init__(self, services):
438 self.services = services
439 self.length = len(services)
442 def selectService(self, service):
448 while self.services[self.current].ref != service:
450 if self.current >= self.length:
454 def nextService(self):
457 if self.current+1 < self.length:
462 def prevService(self):
465 if self.current-1 > -1:
468 self.current = self.length - 1
470 def currentService(self):
471 if not self.length or self.current >= self.length:
473 return self.services[self.current]
476 """ EPG - Opens an EPG list when the showEPGList action fires """
478 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
480 iPlayableService.evUpdatedEventInfo: self.__evEventInfoChanged,
483 self.is_now_next = False
485 self.bouquetSel = None
486 self.eventView = None
487 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
489 "showEventInfo": (self.openEventView, _("show EPG...")),
490 "showEventInfoPlugin": (self.showEventInfoPlugins, _("show single service EPG...")),
491 "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
494 def showEventInfoWhenNotVisible(self):
501 def zapToService(self, service):
502 if not service is None:
503 if self.servicelist.getRoot() != self.epg_bouquet: #already in correct bouquet?
504 self.servicelist.clearPath()
505 if self.servicelist.bouquet_root != self.epg_bouquet:
506 self.servicelist.enterPath(self.servicelist.bouquet_root)
507 self.servicelist.enterPath(self.epg_bouquet)
508 self.servicelist.setCurrentSelection(service) #select the service in servicelist
509 self.servicelist.zap()
511 def getBouquetServices(self, bouquet):
513 servicelist = eServiceCenter.getInstance().list(bouquet)
514 if not servicelist is None:
516 service = servicelist.getNext()
517 if not service.valid(): #check if end of list
519 if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker): #ignore non playable services
521 services.append(ServiceReference(service))
524 def openBouquetEPG(self, bouquet, withCallback=True):
525 services = self.getBouquetServices(bouquet)
527 self.epg_bouquet = bouquet
529 self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService, None, self.changeBouquetCB))
531 self.session.open(EPGSelection, services, self.zapToService, None, self.changeBouquetCB)
533 def changeBouquetCB(self, direction, epg):
536 self.bouquetSel.down()
539 bouquet = self.bouquetSel.getCurrent()
540 services = self.getBouquetServices(bouquet)
542 self.epg_bouquet = bouquet
543 epg.setServices(services)
545 def closed(self, ret=False):
546 closedScreen = self.dlg_stack.pop()
547 if self.bouquetSel and closedScreen == self.bouquetSel:
548 self.bouquetSel = None
549 elif self.eventView and closedScreen == self.eventView:
550 self.eventView = None
552 dlgs=len(self.dlg_stack)
554 self.dlg_stack[dlgs-1].close(dlgs > 1)
556 def openMultiServiceEPG(self, withCallback=True):
557 bouquets = self.servicelist.getBouquetList()
562 if cnt > 1: # show bouquet list
564 self.bouquetSel = self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
565 self.dlg_stack.append(self.bouquetSel)
567 self.bouquetSel = self.session.open(BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
569 self.openBouquetEPG(bouquets[0][1], withCallback)
571 def changeServiceCB(self, direction, epg):
574 self.serviceSel.nextService()
576 self.serviceSel.prevService()
577 epg.setService(self.serviceSel.currentService())
579 def SingleServiceEPGClosed(self, ret=False):
580 self.serviceSel = None
582 def openSingleServiceEPG(self):
583 ref=self.session.nav.getCurrentlyPlayingServiceReference()
585 if self.servicelist.getMutableList() is not None: # bouquet in channellist
586 current_path = self.servicelist.getRoot()
587 services = self.getBouquetServices(current_path)
588 self.serviceSel = SimpleServicelist(services)
589 if self.serviceSel.selectService(ref):
590 self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = self.changeServiceCB)
592 self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref)
594 self.session.open(EPGSelection, ref)
596 def showEventInfoPlugins(self):
597 list = [(p.name, boundFunction(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO)]
600 list.append((_("show single service EPG..."), self.openSingleServiceEPG))
601 list.append((_("Multi EPG"), self.openMultiServiceEPG))
602 self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list, skin_name = "EPGExtensionsList")
604 self.openSingleServiceEPG()
606 def runPlugin(self, plugin):
607 plugin(session = self.session, servicelist = self.servicelist)
609 def EventInfoPluginChosen(self, answer):
610 if answer is not None:
613 def openSimilarList(self, eventid, refstr):
614 self.session.open(EPGSelection, refstr, None, eventid)
616 def getNowNext(self):
618 service = self.session.nav.getCurrentService()
619 info = service and service.info()
620 ptr = info and info.getEvent(0)
623 ptr = info and info.getEvent(1)
626 self.epglist = epglist
628 def __evEventInfoChanged(self):
629 if self.is_now_next and len(self.dlg_stack) == 1:
631 assert self.eventView
633 self.eventView.setEvent(self.epglist[0])
635 def openEventView(self):
636 ref = self.session.nav.getCurrentlyPlayingServiceReference()
638 epglist = self.epglist
640 self.is_now_next = False
641 epg = eEPGCache.getInstance()
642 ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
645 ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
649 self.is_now_next = True
651 self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
652 self.dlg_stack.append(self.eventView)
654 print "no epg for the service avail.. so we show multiepg instead of eventinfo"
655 self.openMultiServiceEPG(False)
657 def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
658 epglist = self.epglist
661 epglist[0]=epglist[1]
665 class InfoBarRdsDecoder:
666 """provides RDS and Rass support/display"""
668 self.rds_display = self.session.instantiateDialog(RdsInfoDisplay)
669 self.rass_interactive = None
671 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
673 iPlayableService.evEnd: self.__serviceStopped,
674 iPlayableService.evUpdatedRassSlidePic: self.RassSlidePicChanged
677 self["RdsActions"] = ActionMap(["InfobarRdsActions"],
679 "startRassInteractive": self.startRassInteractive
682 self["RdsActions"].setEnabled(False)
684 self.onLayoutFinish.append(self.rds_display.show)
685 self.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
687 def RassInteractivePossibilityChanged(self, state):
688 self["RdsActions"].setEnabled(state)
690 def RassSlidePicChanged(self):
691 if not self.rass_interactive:
692 service = self.session.nav.getCurrentService()
693 decoder = service and service.rdsDecoder()
695 decoder.showRassSlidePicture()
697 def __serviceStopped(self):
698 if self.rass_interactive is not None:
699 rass_interactive = self.rass_interactive
700 self.rass_interactive = None
701 rass_interactive.close()
703 def startRassInteractive(self):
704 self.rds_display.hide()
705 self.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
707 def RassInteractiveClosed(self, *val):
708 if self.rass_interactive is not None:
709 self.rass_interactive = None
710 self.RassSlidePicChanged()
711 self.rds_display.show()
714 """handles actions like seeking, pause"""
716 SEEK_STATE_PLAY = (0, 0, 0, ">")
717 SEEK_STATE_PAUSE = (1, 0, 0, "||")
718 SEEK_STATE_EOF = (1, 0, 0, "END")
720 def __init__(self, actionmap = "InfobarSeekActions", useSeekBackHack=True):
721 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
723 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
724 iPlayableService.evStart: self.__serviceStarted,
726 iPlayableService.evEOF: self.__evEOF,
727 iPlayableService.evSOF: self.__evSOF,
729 self.fast_winding_hint_message_showed = False
731 class InfoBarSeekActionMap(HelpableActionMap):
732 def __init__(self, screen, *args, **kwargs):
733 HelpableActionMap.__init__(self, screen, *args, **kwargs)
736 def action(self, contexts, action):
737 print "action:", action
738 if action[:5] == "seek:":
739 time = int(action[5:])
740 self.screen.doSeekRelative(time * 90000)
742 elif action[:8] == "seekdef:":
743 key = int(action[8:])
744 time = (-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value,
745 -config.seek.selfdefined_46.value, False, config.seek.selfdefined_46.value,
746 -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value)[key-1]
747 self.screen.doSeekRelative(time * 90000)
750 return HelpableActionMap.action(self, contexts, action)
752 self["SeekActions"] = InfoBarSeekActionMap(self, actionmap,
754 "playpauseService": self.playpauseService,
755 "pauseService": (self.pauseService, _("pause")),
756 "unPauseService": (self.unPauseService, _("continue")),
758 "seekFwd": (self.seekFwd, _("skip forward")),
759 "seekFwdManual": (self.seekFwdManual, _("skip forward (enter time)")),
760 "seekBack": (self.seekBack, _("skip backward")),
761 "seekBackManual": (self.seekBackManual, _("skip backward (enter time)"))
763 # give them a little more priority to win over color buttons
765 self["SeekActions"].setEnabled(False)
767 self.seekstate = self.SEEK_STATE_PLAY
768 self.lastseekstate = self.SEEK_STATE_PLAY
770 self.onPlayStateChanged = [ ]
772 self.lockedBecauseOfSkipping = False
774 self.__seekableStatusChanged()
776 def makeStateForward(self, n):
777 # minspeed = config.seek.stepwise_minspeed.value
778 # repeat = int(config.seek.stepwise_repeat.value)
779 # if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
780 # return (0, n * repeat, repeat, ">> %dx" % n)
782 return (0, n, 0, ">> %dx" % n)
784 def makeStateBackward(self, n):
785 # minspeed = config.seek.stepwise_minspeed.value
786 # repeat = int(config.seek.stepwise_repeat.value)
787 # if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
788 # return (0, -n * repeat, repeat, "<< %dx" % n)
790 return (0, -n, 0, "<< %dx" % n)
792 def makeStateSlowMotion(self, n):
793 return (0, 0, n, "/%d" % n)
795 def isStateForward(self, state):
798 def isStateBackward(self, state):
801 def isStateSlowMotion(self, state):
802 return state[1] == 0 and state[2] > 1
804 def getHigher(self, n, lst):
810 def getLower(self, n, lst):
818 def showAfterSeek(self):
819 if isinstance(self, InfoBarShowHide):
829 service = self.session.nav.getCurrentService()
833 seek = service.seek()
835 if seek is None or not seek.isCurrentlySeekable():
840 def isSeekable(self):
841 if self.getSeek() is None:
845 def __seekableStatusChanged(self):
846 # print "seekable status changed!"
847 if not self.isSeekable():
848 self["SeekActions"].setEnabled(False)
849 # print "not seekable, return to play"
850 self.setSeekState(self.SEEK_STATE_PLAY)
852 self["SeekActions"].setEnabled(True)
855 def __serviceStarted(self):
856 self.fast_winding_hint_message_showed = False
857 self.seekstate = self.SEEK_STATE_PLAY
858 self.__seekableStatusChanged()
860 def setSeekState(self, state):
861 service = self.session.nav.getCurrentService()
866 if not self.isSeekable():
867 if state not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE):
868 state = self.SEEK_STATE_PLAY
870 pauseable = service.pause()
872 if pauseable is None:
873 print "not pauseable."
874 state = self.SEEK_STATE_PLAY
876 self.seekstate = state
878 if pauseable is not None:
879 if self.seekstate[0]:
880 print "resolved to PAUSE"
882 elif self.seekstate[1]:
883 print "resolved to FAST FORWARD"
884 pauseable.setFastForward(self.seekstate[1])
885 elif self.seekstate[2]:
886 print "resolved to SLOW MOTION"
887 pauseable.setSlowMotion(self.seekstate[2])
889 print "resolved to PLAY"
892 for c in self.onPlayStateChanged:
895 self.checkSkipShowHideLock()
899 def playpauseService(self):
900 if self.seekstate != self.SEEK_STATE_PLAY:
901 self.unPauseService()
905 def pauseService(self):
906 if self.seekstate == self.SEEK_STATE_PAUSE:
907 if config.seek.on_pause.value == "play":
908 self.unPauseService()
909 elif config.seek.on_pause.value == "step":
910 self.doSeekRelative(1)
911 elif config.seek.on_pause.value == "last":
912 self.setSeekState(self.lastseekstate)
913 self.lastseekstate = self.SEEK_STATE_PLAY
915 if self.seekstate != self.SEEK_STATE_EOF:
916 self.lastseekstate = self.seekstate
917 self.setSeekState(self.SEEK_STATE_PAUSE);
919 def unPauseService(self):
921 if self.seekstate == self.SEEK_STATE_PLAY:
923 self.setSeekState(self.SEEK_STATE_PLAY)
925 def doSeek(self, pts):
926 seekable = self.getSeek()
931 def doSeekRelative(self, pts):
932 seekable = self.getSeek()
935 prevstate = self.seekstate
937 if self.seekstate == self.SEEK_STATE_EOF:
938 if prevstate == self.SEEK_STATE_PAUSE:
939 self.setSeekState(self.SEEK_STATE_PAUSE)
941 self.setSeekState(self.SEEK_STATE_PLAY)
942 seekable.seekRelative(pts<0 and -1 or 1, abs(pts))
943 if abs(pts) > 100 and config.usage.show_infobar_on_skip.value:
947 seek = self.getSeek()
948 if seek and not (seek.isCurrentlySeekable() & 2):
949 if not self.fast_winding_hint_message_showed and (seek.isCurrentlySeekable() & 1):
950 self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10)
951 self.fast_winding_hint_message_showed = True
953 return 0 # trade as unhandled action
954 if self.seekstate == self.SEEK_STATE_PLAY:
955 self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
956 elif self.seekstate == self.SEEK_STATE_PAUSE:
957 if len(config.seek.speeds_slowmotion.value):
958 self.setSeekState(self.makeStateSlowMotion(config.seek.speeds_slowmotion.value[-1]))
960 self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
961 elif self.seekstate == self.SEEK_STATE_EOF:
963 elif self.isStateForward(self.seekstate):
964 speed = self.seekstate[1]
965 if self.seekstate[2]:
966 speed /= self.seekstate[2]
967 speed = self.getHigher(speed, config.seek.speeds_forward.value) or config.seek.speeds_forward.value[-1]
968 self.setSeekState(self.makeStateForward(speed))
969 elif self.isStateBackward(self.seekstate):
970 speed = -self.seekstate[1]
971 if self.seekstate[2]:
972 speed /= self.seekstate[2]
973 speed = self.getLower(speed, config.seek.speeds_backward.value)
975 self.setSeekState(self.makeStateBackward(speed))
977 self.setSeekState(self.SEEK_STATE_PLAY)
978 elif self.isStateSlowMotion(self.seekstate):
979 speed = self.getLower(self.seekstate[2], config.seek.speeds_slowmotion.value) or config.seek.speeds_slowmotion.value[0]
980 self.setSeekState(self.makeStateSlowMotion(speed))
983 seek = self.getSeek()
984 if seek and not (seek.isCurrentlySeekable() & 2):
985 if not self.fast_winding_hint_message_showed and (seek.isCurrentlySeekable() & 1):
986 self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10)
987 self.fast_winding_hint_message_showed = True
989 return 0 # trade as unhandled action
990 seekstate = self.seekstate
991 if seekstate == self.SEEK_STATE_PLAY:
992 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
993 elif seekstate == self.SEEK_STATE_EOF:
994 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
995 self.doSeekRelative(-6)
996 elif seekstate == self.SEEK_STATE_PAUSE:
997 self.doSeekRelative(-1)
998 elif self.isStateForward(seekstate):
1001 speed /= seekstate[2]
1002 speed = self.getLower(speed, config.seek.speeds_forward.value)
1004 self.setSeekState(self.makeStateForward(speed))
1006 self.setSeekState(self.SEEK_STATE_PLAY)
1007 elif self.isStateBackward(seekstate):
1008 speed = -seekstate[1]
1010 speed /= seekstate[2]
1011 speed = self.getHigher(speed, config.seek.speeds_backward.value) or config.seek.speeds_backward.value[-1]
1012 self.setSeekState(self.makeStateBackward(speed))
1013 elif self.isStateSlowMotion(seekstate):
1014 speed = self.getHigher(seekstate[2], config.seek.speeds_slowmotion.value)
1016 self.setSeekState(self.makeStateSlowMotion(speed))
1018 self.setSeekState(self.SEEK_STATE_PAUSE)
1020 def seekFwdManual(self):
1021 self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
1023 def fwdSeekTo(self, minutes):
1024 print "Seek", minutes, "minutes forward"
1025 self.doSeekRelative(minutes * 60 * 90000)
1027 def seekBackManual(self):
1028 self.session.openWithCallback(self.rwdSeekTo, MinuteInput)
1030 def rwdSeekTo(self, minutes):
1032 self.doSeekRelative(-minutes * 60 * 90000)
1034 def checkSkipShowHideLock(self):
1035 wantlock = self.seekstate != self.SEEK_STATE_PLAY
1037 if config.usage.show_infobar_on_skip.value:
1038 if self.lockedBecauseOfSkipping and not wantlock:
1040 self.lockedBecauseOfSkipping = False
1042 if wantlock and not self.lockedBecauseOfSkipping:
1044 self.lockedBecauseOfSkipping = True
1046 def calcRemainingTime(self):
1047 seekable = self.getSeek()
1048 if seekable is not None:
1049 len = seekable.getLength()
1051 tmp = self.cueGetEndCutPosition()
1056 pos = seekable.getPlayPosition()
1057 speednom = self.seekstate[1] or 1
1058 speedden = self.seekstate[2] or 1
1059 if not len[0] and not pos[0]:
1060 if len[1] <= pos[1]:
1062 time = (len[1] - pos[1])*speedden/(90*speednom)
1067 if self.seekstate == self.SEEK_STATE_EOF:
1070 # if we are seeking forward, we try to end up ~1s before the end, and pause there.
1071 seekstate = self.seekstate
1072 if self.seekstate != self.SEEK_STATE_PAUSE:
1073 self.setSeekState(self.SEEK_STATE_EOF)
1075 if seekstate not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): # if we are seeking
1076 seekable = self.getSeek()
1077 if seekable is not None:
1079 if seekstate == self.SEEK_STATE_PLAY: # regular EOF
1080 self.doEofInternal(True)
1082 self.doEofInternal(False)
1084 def doEofInternal(self, playing):
1085 pass # Defined in subclasses
1088 self.setSeekState(self.SEEK_STATE_PLAY)
1091 from Screens.PVRState import PVRState, TimeshiftState
1093 class InfoBarPVRState:
1094 def __init__(self, screen=PVRState, force_show = False):
1095 self.onPlayStateChanged.append(self.__playStateChanged)
1096 self.pvrStateDialog = self.session.instantiateDialog(screen)
1097 self.onShow.append(self._mayShow)
1098 self.onHide.append(self.pvrStateDialog.hide)
1099 self.force_show = force_show
1102 if self.execing and self.seekstate != self.SEEK_STATE_PLAY:
1103 self.pvrStateDialog.show()
1105 def __playStateChanged(self, state):
1106 playstateString = state[3]
1107 self.pvrStateDialog["state"].setText(playstateString)
1109 # if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed
1110 if not config.usage.show_infobar_on_skip.value and self.seekstate == self.SEEK_STATE_PLAY and not self.force_show:
1111 self.pvrStateDialog.hide()
1116 class InfoBarTimeshiftState(InfoBarPVRState):
1118 InfoBarPVRState.__init__(self, screen=TimeshiftState, force_show = True)
1121 if self.execing and self.timeshift_enabled and self.seekstate != self.SEEK_STATE_PLAY:
1122 self.pvrStateDialog.show()
1124 class InfoBarShowMovies:
1126 # i don't really like this class.
1127 # it calls a not further specified "movie list" on up/down/movieList,
1128 # so this is not more than an action map
1130 self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions",
1132 "movieList": (self.showMovies, _("movie list")),
1133 "up": (self.showMovies, _("movie list")),
1134 "down": (self.showMovies, _("movie list"))
1137 # InfoBarTimeshift requires InfoBarSeek, instantiated BEFORE!
1141 # Timeshift works the following way:
1142 # demux0 demux1 "TimeshiftActions" "TimeshiftActivateActions" "SeekActions"
1143 # - normal playback TUNER unused PLAY enable disable disable
1144 # - user presses "yellow" button. FILE record PAUSE enable disable enable
1145 # - user presess pause again FILE record PLAY enable disable enable
1146 # - user fast forwards FILE record FF enable disable enable
1147 # - end of timeshift buffer reached TUNER record PLAY enable enable disable
1148 # - user backwards FILE record BACK # !! enable disable enable
1152 # - when a service is playing, pressing the "timeshiftStart" button ("yellow") enables recording ("enables timeshift"),
1153 # freezes the picture (to indicate timeshift), sets timeshiftMode ("activates timeshift")
1154 # now, the service becomes seekable, so "SeekActions" are enabled, "TimeshiftEnableActions" are disabled.
1155 # - the user can now PVR around
1156 # - if it hits the end, the service goes into live mode ("deactivates timeshift", it's of course still "enabled")
1157 # the service looses it's "seekable" state. It can still be paused, but just to activate timeshift right
1159 # the seek actions will be disabled, but the timeshiftActivateActions will be enabled
1160 # - if the user rewinds, or press pause, timeshift will be activated again
1162 # note that a timeshift can be enabled ("recording") and
1163 # activated (currently time-shifting).
1165 class InfoBarTimeshift:
1167 self["TimeshiftActions"] = HelpableActionMap(self, "InfobarTimeshiftActions",
1169 "timeshiftStart": (self.startTimeshift, _("start timeshift")), # the "yellow key"
1170 "timeshiftStop": (self.stopTimeshift, _("stop timeshift")) # currently undefined :), probably 'TV'
1172 self["TimeshiftActivateActions"] = ActionMap(["InfobarTimeshiftActivateActions"],
1174 "timeshiftActivateEnd": self.activateTimeshiftEnd, # something like "rewind key"
1175 "timeshiftActivateEndAndPause": self.activateTimeshiftEndAndPause # something like "pause key"
1176 }, prio=-1) # priority over record
1178 self.timeshift_enabled = 0
1179 self.timeshift_state = 0
1180 self.ts_rewind_timer = eTimer()
1181 self.ts_rewind_timer.callback.append(self.rewindService)
1183 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1185 iPlayableService.evStart: self.__serviceStarted,
1186 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged
1189 def getTimeshift(self):
1190 service = self.session.nav.getCurrentService()
1191 return service and service.timeshift()
1193 def startTimeshift(self):
1194 print "enable timeshift"
1195 ts = self.getTimeshift()
1197 self.session.open(MessageBox, _("Timeshift not possible!"), MessageBox.TYPE_ERROR)
1198 print "no ts interface"
1201 if self.timeshift_enabled:
1202 print "hu, timeshift already enabled?"
1204 if not ts.startTimeshift():
1205 self.timeshift_enabled = 1
1207 # we remove the "relative time" for now.
1208 #self.pvrStateDialog["timeshift"].setRelative(time.time())
1211 #self.setSeekState(self.SEEK_STATE_PAUSE)
1212 self.activateTimeshiftEnd(False)
1214 # enable the "TimeshiftEnableActions", which will override
1215 # the startTimeshift actions
1216 self.__seekableStatusChanged()
1218 print "timeshift failed"
1220 def stopTimeshift(self):
1221 if not self.timeshift_enabled:
1223 print "disable timeshift"
1224 ts = self.getTimeshift()
1227 self.session.openWithCallback(self.stopTimeshiftConfirmed, MessageBox, _("Stop Timeshift?"), MessageBox.TYPE_YESNO)
1229 def stopTimeshiftConfirmed(self, confirmed):
1233 ts = self.getTimeshift()
1238 self.timeshift_enabled = 0
1241 self.__seekableStatusChanged()
1243 # activates timeshift, and seeks to (almost) the end
1244 def activateTimeshiftEnd(self, back = True):
1245 ts = self.getTimeshift()
1246 print "activateTimeshiftEnd"
1251 if ts.isTimeshiftActive():
1252 print "!! activate timeshift called - but shouldn't this be a normal pause?"
1256 ts.activateTimeshift() # activate timeshift will automatically pause
1257 self.setSeekState(self.SEEK_STATE_PAUSE)
1260 self.ts_rewind_timer.start(200, 1)
1262 def rewindService(self):
1263 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
1265 # same as activateTimeshiftEnd, but pauses afterwards.
1266 def activateTimeshiftEndAndPause(self):
1267 print "activateTimeshiftEndAndPause"
1268 #state = self.seekstate
1269 self.activateTimeshiftEnd(False)
1271 def __seekableStatusChanged(self):
1274 # print "self.isSeekable", self.isSeekable()
1275 # print "self.timeshift_enabled", self.timeshift_enabled
1277 # when this service is not seekable, but timeshift
1278 # is enabled, this means we can activate
1280 if not self.isSeekable() and self.timeshift_enabled:
1283 # print "timeshift activate:", enabled
1284 self["TimeshiftActivateActions"].setEnabled(enabled)
1286 def __serviceStarted(self):
1287 self.timeshift_enabled = False
1288 self.__seekableStatusChanged()
1290 from Screens.PiPSetup import PiPSetup
1292 class InfoBarExtensions:
1293 EXTENSION_SINGLE = 0
1299 self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
1301 "extensions": (self.showExtensionSelection, _("view extensions...")),
1302 }, 1) # lower priority
1304 def addExtension(self, extension, key = None, type = EXTENSION_SINGLE):
1305 self.list.append((type, extension, key))
1307 def updateExtension(self, extension, key = None):
1308 self.extensionsList.append(extension)
1310 if self.extensionKeys.has_key(key):
1314 for x in self.availableKeys:
1315 if not self.extensionKeys.has_key(x):
1320 self.extensionKeys[key] = len(self.extensionsList) - 1
1322 def updateExtensions(self):
1323 self.extensionsList = []
1324 self.availableKeys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ]
1325 self.extensionKeys = {}
1327 if x[0] == self.EXTENSION_SINGLE:
1328 self.updateExtension(x[1], x[2])
1331 self.updateExtension(y[0], y[1])
1334 def showExtensionSelection(self):
1335 self.updateExtensions()
1336 extensionsList = self.extensionsList[:]
1339 for x in self.availableKeys:
1340 if self.extensionKeys.has_key(x):
1341 entry = self.extensionKeys[x]
1342 extension = self.extensionsList[entry]
1344 name = str(extension[0]())
1345 list.append((extension[0](), extension))
1347 extensionsList.remove(extension)
1349 extensionsList.remove(extension)
1350 list.extend([(x[0](), x) for x in extensionsList])
1352 keys += [""] * len(extensionsList)
1353 self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys, skin_name = "ExtensionsList")
1355 def extensionCallback(self, answer):
1356 if answer is not None:
1359 from Tools.BoundFunction import boundFunction
1361 # depends on InfoBarExtensions
1363 class InfoBarPlugins:
1365 self.addExtension(extension = self.getPluginList, type = InfoBarExtensions.EXTENSION_LIST)
1367 def getPluginName(self, name):
1370 def getPluginList(self):
1371 list = [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None, p.name) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)]
1372 list.sort(key = lambda e: e[2]) # sort by name
1375 def runPlugin(self, plugin):
1376 if isinstance(self, InfoBarChannelSelection):
1377 plugin(session = self.session, servicelist = self.servicelist)
1379 plugin(session = self.session)
1381 from Components.Task import job_manager
1382 class InfoBarJobman:
1384 self.addExtension(extension = self.getJobList, type = InfoBarExtensions.EXTENSION_LIST)
1386 def getJobList(self):
1387 return [((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None) for job in job_manager.getPendingJobs()]
1389 def getJobName(self, job):
1390 return "%s: %s (%d%%)" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end)))
1392 def showJobView(self, job):
1393 from Screens.TaskView import JobView
1394 job_manager.in_background = False
1395 self.session.openWithCallback(self.JobViewCB, JobView, job)
1397 def JobViewCB(self, in_background):
1398 job_manager.in_background = in_background
1400 # depends on InfoBarExtensions
1404 self.session.pipshown
1406 self.session.pipshown = False
1407 if SystemInfo.get("NumVideoDecoders", 1) > 1:
1409 self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
1410 self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
1411 self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
1413 self.addExtension((self.getShowHideName, self.showPiP, self.pipShown), "blue")
1414 self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
1417 return self.session.pipshown
1419 def pipHandles0Action(self):
1420 return self.pipShown() and config.usage.pip_zero_button.value != "standard"
1422 def getShowHideName(self):
1423 if self.session.pipshown:
1424 return _("Disable Picture in Picture")
1426 return _("Activate Picture in Picture")
1428 def getSwapName(self):
1429 return _("Swap Services")
1431 def getMoveName(self):
1432 return _("Move Picture in Picture")
1435 if self.session.pipshown:
1436 del self.session.pip
1437 self.session.pipshown = False
1439 self.session.pip = self.session.instantiateDialog(PictureInPicture)
1440 self.session.pip.show()
1441 newservice = self.session.nav.getCurrentlyPlayingServiceReference()
1442 if self.session.pip.playService(newservice):
1443 self.session.pipshown = True
1444 self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
1446 self.session.pipshown = False
1447 del self.session.pip
1448 self.session.nav.playService(newservice)
1451 swapservice = self.session.nav.getCurrentlyPlayingServiceReference()
1452 if self.session.pip.servicePath:
1453 servicepath = self.servicelist.getCurrentServicePath()
1454 ref=servicepath[len(servicepath)-1]
1455 pipref=self.session.pip.getCurrentService()
1456 self.session.pip.playService(swapservice)
1457 self.servicelist.setCurrentServicePath(self.session.pip.servicePath)
1458 if pipref.toString() != ref.toString(): # is a subservice ?
1459 self.session.nav.stopService() # stop portal
1460 self.session.nav.playService(pipref) # start subservice
1461 self.session.pip.servicePath=servicepath
1464 self.session.open(PiPSetup, pip = self.session.pip)
1466 def pipDoHandle0Action(self):
1467 use = config.usage.pip_zero_button.value
1470 elif "swapstop" == use:
1476 from RecordTimer import parseEvent, RecordTimerEntry
1478 class InfoBarInstantRecord:
1479 """Instant Record - handles the instantRecord action in order to
1480 start/stop instant records"""
1482 self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
1484 "instantRecord": (self.instantRecord, _("Instant Record...")),
1488 def stopCurrentRecording(self, entry = -1):
1489 if entry is not None and entry != -1:
1490 self.session.nav.RecordTimer.removeEntry(self.recording[entry])
1491 self.recording.remove(self.recording[entry])
1493 def startInstantRecording(self, limitEvent = False):
1494 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
1496 # try to get event info
1499 service = self.session.nav.getCurrentService()
1500 epg = eEPGCache.getInstance()
1501 event = epg.lookupEventTime(serviceref, -1, 0)
1503 info = service.info()
1504 ev = info.getEvent(0)
1510 end = begin + 3600 # dummy
1511 name = "instant record"
1515 if event is not None:
1516 curEvent = parseEvent(event)
1518 description = curEvent[3]
1519 eventid = curEvent[4]
1524 self.session.open(MessageBox, _("No event info found, recording indefinitely."), MessageBox.TYPE_INFO)
1526 if isinstance(serviceref, eServiceReference):
1527 serviceref = ServiceReference(serviceref)
1529 recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = preferredInstantRecordPath())
1530 recording.dontSave = True
1532 if event is None or limitEvent == False:
1533 recording.autoincrease = True
1534 if recording.setAutoincreaseEnd():
1535 self.session.nav.RecordTimer.record(recording)
1536 self.recording.append(recording)
1538 simulTimerList = self.session.nav.RecordTimer.record(recording)
1539 if simulTimerList is not None: # conflict with other recording
1540 name = simulTimerList[1].name
1541 name_date = ' '.join((name, strftime('%c', localtime(simulTimerList[1].begin))))
1542 print "[TIMER] conflicts with", name_date
1543 recording.autoincrease = True # start with max available length, then increment
1544 if recording.setAutoincreaseEnd():
1545 self.session.nav.RecordTimer.record(recording)
1546 self.recording.append(recording)
1547 self.session.open(MessageBox, _("Record time limited due to conflicting timer %s") % name_date, MessageBox.TYPE_INFO)
1549 self.session.open(MessageBox, _("Couldn't record due to conflicting timer %s") % name, MessageBox.TYPE_INFO)
1550 recording.autoincrease = False
1552 self.recording.append(recording)
1554 def isInstantRecordRunning(self):
1555 print "self.recording:", self.recording
1557 for x in self.recording:
1562 def recordQuestionCallback(self, answer):
1563 print "pre:\n", self.recording
1565 if answer is None or answer[1] == "no":
1568 recording = self.recording[:]
1570 if not x in self.session.nav.RecordTimer.timer_list:
1571 self.recording.remove(x)
1572 elif x.dontSave and x.isRunning():
1573 list.append((x, False))
1575 if answer[1] == "changeduration":
1576 if len(self.recording) == 1:
1577 self.changeDuration(0)
1579 self.session.openWithCallback(self.changeDuration, TimerSelection, list)
1580 elif answer[1] == "changeendtime":
1581 if len(self.recording) == 1:
1584 self.session.openWithCallback(self.setEndtime, TimerSelection, list)
1585 elif answer[1] == "stop":
1586 if len(self.recording) == 1:
1587 self.stopCurrentRecording(0)
1589 self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
1590 elif answer[1] in ( "indefinitely" , "manualduration", "manualendtime", "event"):
1591 self.startInstantRecording(limitEvent = answer[1] in ("event", "manualendtime") or False)
1592 if answer[1] == "manualduration":
1593 self.changeDuration(len(self.recording)-1)
1594 elif answer[1] == "manualendtime":
1595 self.setEndtime(len(self.recording)-1)
1596 print "after:\n", self.recording
1598 def setEndtime(self, entry):
1599 if entry is not None and entry >= 0:
1600 self.selectedEntry = entry
1601 self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end)
1602 dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime)
1603 dlg.setTitle(_("Please change recording endtime"))
1605 def TimeDateInputClosed(self, ret):
1608 localendtime = localtime(ret[1])
1609 print "stopping recording at", strftime("%c", localendtime)
1610 if self.recording[self.selectedEntry].end != ret[1]:
1611 self.recording[self.selectedEntry].autoincrease = False
1612 self.recording[self.selectedEntry].end = ret[1]
1613 self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
1615 def changeDuration(self, entry):
1616 if entry is not None and entry >= 0:
1617 self.selectedEntry = entry
1618 self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5", maxSize=False, type=Input.NUMBER)
1620 def inputCallback(self, value):
1621 if value is not None:
1622 print "stopping recording after", int(value), "minutes."
1623 entry = self.recording[self.selectedEntry]
1625 entry.autoincrease = False
1626 entry.end = int(time()) + 60 * int(value)
1627 self.session.nav.RecordTimer.timeChanged(entry)
1629 def instantRecord(self):
1630 dir = preferredInstantRecordPath()
1631 if not dir or not fileExists(dir, 'w'):
1632 dir = defaultMoviePath()
1636 # XXX: this message is a little odd as we might be recording to a remote device
1637 self.session.open(MessageBox, _("No HDD found or HDD not initialized!"), MessageBox.TYPE_ERROR)
1640 if self.isInstantRecordRunning():
1641 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1642 title=_("A recording is currently running.\nWhat do you want to do?"), \
1643 list=((_("stop recording"), "stop"), \
1644 (_("add recording (stop after current event)"), "event"), \
1645 (_("add recording (indefinitely)"), "indefinitely"), \
1646 (_("add recording (enter recording duration)"), "manualduration"), \
1647 (_("add recording (enter recording endtime)"), "manualendtime"), \
1648 (_("change recording (duration)"), "changeduration"), \
1649 (_("change recording (endtime)"), "changeendtime"), \
1650 (_("do nothing"), "no")))
1652 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1653 title=_("Start recording?"), \
1654 list=((_("add recording (stop after current event)"), "event"), \
1655 (_("add recording (indefinitely)"), "indefinitely"), \
1656 (_("add recording (enter recording duration)"), "manualduration"), \
1657 (_("add recording (enter recording endtime)"), "manualendtime"), \
1658 (_("don't record"), "no")))
1660 from Tools.ISO639 import LanguageCodes
1662 class InfoBarAudioSelection:
1664 self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
1666 "audioSelection": (self.audioSelection, _("Audio Options...")),
1669 def audioSelection(self):
1670 service = self.session.nav.getCurrentService()
1671 self.audioTracks = audio = service and service.audioTracks()
1672 n = audio and audio.getNumberOfTracks() or 0
1675 self.audioChannel = service.audioChannel()
1680 i = audio.getTrackInfo(idx)
1681 languages = i.getLanguage().split('/')
1682 description = i.getDescription()
1685 for lang in languages:
1688 if LanguageCodes.has_key(lang):
1689 language += LanguageCodes[lang][0]
1694 if len(description):
1695 description += " (" + language + ")"
1697 description = language
1699 tlist.append((description, idx))
1702 tlist.sort(key=lambda x: x[0])
1704 selectedAudio = self.audioTracks.getCurrentTrack()
1709 if x[1] != selectedAudio:
1717 if SystemInfo["CanDownmixAC3"]:
1718 flist = [(_("AC3 downmix") + " - " +(_("Off"), _("On"))[config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix),
1719 ((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode")]
1720 usedKeys.extend(["red", "green"])
1721 availableKeys.extend(["yellow", "blue"])
1724 flist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode")]
1725 usedKeys.extend(["red"])
1726 availableKeys.extend(["green", "yellow", "blue"])
1729 if hasattr(self, "runPlugin"):
1731 def __init__(self, fnc, *args):
1734 def __call__(self, *args, **kwargs):
1735 self.fnc(*self.args)
1737 Plugins = [ (p.name, PluginCaller(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ]
1741 flist.append((p[0], "CALLFUNC", p[1]))
1743 usedKeys.append(availableKeys[0])
1744 del availableKeys[0]
1748 flist.append(("--", ""))
1752 keys = usedKeys + [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ] + [""] * n
1753 self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = flist + tlist, selection = selection, keys = keys, skin_name = "AudioTrackSelection")
1755 del self.audioTracks
1757 def changeAC3Downmix(self, arg):
1758 choicelist = self.session.current_dialog["list"]
1759 list = choicelist.list
1761 list[0][1]=(t[0], t[1], t[2], t[3], t[4], t[5], t[6],
1762 _("AC3 downmix") + " - " + (_("On"), _("Off"))[config.av.downmix_ac3.value and 1 or 0])
1763 choicelist.setList(list)
1764 if config.av.downmix_ac3.value:
1765 config.av.downmix_ac3.value = False
1767 config.av.downmix_ac3.value = True
1768 config.av.downmix_ac3.save()
1770 def audioSelected(self, audio):
1771 if audio is not None:
1772 if isinstance(audio[1], str):
1773 if audio[1] == "mode":
1774 keys = ["red", "green", "yellow"]
1775 selection = self.audioChannel.getCurrentChannel()
1776 tlist = ((_("left"), 0), (_("stereo"), 1), (_("right"), 2))
1777 self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys, skin_name ="AudioModeSelection")
1779 del self.audioChannel
1780 if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]:
1781 self.audioTracks.selectTrack(audio[1])
1783 del self.audioChannel
1784 del self.audioTracks
1786 def modeSelected(self, mode):
1787 if mode is not None:
1788 self.audioChannel.selectChannel(mode[1])
1789 del self.audioChannel
1791 class InfoBarSubserviceSelection:
1793 self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",
1795 "subserviceSelection": (self.subserviceSelection, _("Subservice list...")),
1798 self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions",
1800 "nextSubservice": (self.nextSubservice, _("Switch to next subservice")),
1801 "prevSubservice": (self.prevSubservice, _("Switch to previous subservice"))
1803 self["SubserviceQuickzapAction"].setEnabled(False)
1805 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1807 iPlayableService.evUpdatedEventInfo: self.checkSubservicesAvail
1812 def checkSubservicesAvail(self):
1813 service = self.session.nav.getCurrentService()
1814 subservices = service and service.subServices()
1815 if not subservices or subservices.getNumberOfSubservices() == 0:
1816 self["SubserviceQuickzapAction"].setEnabled(False)
1818 def nextSubservice(self):
1819 self.changeSubservice(+1)
1821 def prevSubservice(self):
1822 self.changeSubservice(-1)
1824 def changeSubservice(self, direction):
1825 service = self.session.nav.getCurrentService()
1826 subservices = service and service.subServices()
1827 n = subservices and subservices.getNumberOfSubservices()
1830 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1833 if subservices.getSubservice(idx).toString() == ref.toString():
1838 selection += direction
1843 newservice = subservices.getSubservice(selection)
1844 if newservice.valid():
1847 self.session.nav.playService(newservice, False)
1849 def subserviceSelection(self):
1850 service = self.session.nav.getCurrentService()
1851 subservices = service and service.subServices()
1852 self.bouquets = self.servicelist.getBouquetList()
1853 n = subservices and subservices.getNumberOfSubservices()
1856 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1860 i = subservices.getSubservice(idx)
1861 if i.toString() == ref.toString():
1863 tlist.append((i.getName(), i))
1866 if self.bouquets and len(self.bouquets):
1867 keys = ["red", "blue", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1868 if config.usage.multibouquet.value:
1869 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to bouquet"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1871 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to favourites"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1874 tlist = [(_("Quickzap"), "quickzap", service.subServices()), ("--", "")] + tlist
1875 keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1878 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys, skin_name = "SubserviceSelection")
1880 def subserviceSelected(self, service):
1882 if not service is None:
1883 if isinstance(service[1], str):
1884 if service[1] == "quickzap":
1885 from Screens.SubservicesQuickzap import SubservicesQuickzap
1886 self.session.open(SubservicesQuickzap, service[2])
1888 self["SubserviceQuickzapAction"].setEnabled(True)
1889 self.session.nav.playService(service[1], False)
1891 def addSubserviceToBouquetCallback(self, service):
1892 if len(service) > 1 and isinstance(service[1], eServiceReference):
1893 self.selectedSubservice = service
1894 if self.bouquets is None:
1897 cnt = len(self.bouquets)
1898 if cnt > 1: # show bouquet list
1899 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, self.bouquets, self.addSubserviceToBouquet)
1900 elif cnt == 1: # add to only one existing bouquet
1901 self.addSubserviceToBouquet(self.bouquets[0][1])
1902 self.session.open(MessageBox, _("Service has been added to the favourites."), MessageBox.TYPE_INFO)
1904 def bouquetSelClosed(self, confirmed):
1906 del self.selectedSubservice
1908 self.session.open(MessageBox, _("Service has been added to the selected bouquet."), MessageBox.TYPE_INFO)
1910 def addSubserviceToBouquet(self, dest):
1911 self.servicelist.addServiceToBouquet(dest, self.selectedSubservice[1])
1913 self.bsel.close(True)
1915 del self.selectedSubservice
1917 class InfoBarAdditionalInfo:
1920 self["RecordingPossible"] = Boolean(fixed=harddiskmanager.HDDCount() > 0 and config.misc.rcused.value == 1)
1921 self["TimeshiftPossible"] = self["RecordingPossible"]
1922 self["ShowTimeshiftOnYellow"] = Boolean(fixed=(not config.misc.rcused.value == 0))
1923 self["ShowAudioOnYellow"] = Boolean(fixed=config.misc.rcused.value == 0)
1924 self["ShowRecordOnRed"] = Boolean(fixed=config.misc.rcused.value == 1)
1925 self["ExtensionsAvailable"] = Boolean(fixed=1)
1927 class InfoBarNotifications:
1929 self.onExecBegin.append(self.checkNotifications)
1930 Notifications.notificationAdded.append(self.checkNotificationsIfExecing)
1931 self.onClose.append(self.__removeNotification)
1933 def __removeNotification(self):
1934 Notifications.notificationAdded.remove(self.checkNotificationsIfExecing)
1936 def checkNotificationsIfExecing(self):
1938 self.checkNotifications()
1940 def checkNotifications(self):
1941 notifications = Notifications.notifications
1943 n = notifications[0]
1945 del notifications[0]
1948 if n[3].has_key("onSessionOpenCallback"):
1949 n[3]["onSessionOpenCallback"]()
1950 del n[3]["onSessionOpenCallback"]
1953 dlg = self.session.openWithCallback(cb, n[1], *n[2], **n[3])
1955 dlg = self.session.open(n[1], *n[2], **n[3])
1957 # remember that this notification is currently active
1959 Notifications.current_notifications.append(d)
1960 dlg.onClose.append(boundFunction(self.__notificationClosed, d))
1962 def __notificationClosed(self, d):
1963 Notifications.current_notifications.remove(d)
1965 class InfoBarServiceNotifications:
1967 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1969 iPlayableService.evEnd: self.serviceHasEnded
1972 def serviceHasEnded(self):
1973 print "service end!"
1976 self.setSeekState(self.SEEK_STATE_PLAY)
1980 class InfoBarCueSheetSupport:
1986 ENABLE_RESUME_SUPPORT = False
1988 def __init__(self, actionmap = "InfobarCueSheetActions"):
1989 self["CueSheetActions"] = HelpableActionMap(self, actionmap,
1991 "jumpPreviousMark": (self.jumpPreviousMark, _("jump to previous marked position")),
1992 "jumpNextMark": (self.jumpNextMark, _("jump to next marked position")),
1993 "toggleMark": (self.toggleMark, _("toggle a cut mark at the current position"))
1997 self.is_closing = False
1998 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2000 iPlayableService.evStart: self.__serviceStarted,
2003 def __serviceStarted(self):
2006 print "new service started! trying to download cuts!"
2007 self.downloadCuesheet()
2009 if self.ENABLE_RESUME_SUPPORT:
2012 for (pts, what) in self.cut_list:
2013 if what == self.CUT_TYPE_LAST:
2016 if last is not None:
2017 self.resume_point = last
2020 if config.usage.on_movie_start.value == "ask":
2021 Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Do you want to resume this playback?") + "\n" + (_("Resume position at %s") % ("%d:%02d:%02d" % (l/3600, l%3600/60, l%60))), timeout=10)
2022 elif config.usage.on_movie_start.value == "resume":
2023 # TRANSLATORS: The string "Resuming playback" flashes for a moment
2024 # TRANSLATORS: at the start of a movie, when the user has selected
2025 # TRANSLATORS: "Resume from last position" as start behavior.
2026 # TRANSLATORS: The purpose is to notify the user that the movie starts
2027 # TRANSLATORS: in the middle somewhere and not from the beginning.
2028 # TRANSLATORS: (Some translators seem to have interpreted it as a
2029 # TRANSLATORS: question or a choice, but it is a statement.)
2030 Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Resuming playback"), timeout=2, type=MessageBox.TYPE_INFO)
2032 def playLastCB(self, answer):
2034 self.doSeek(self.resume_point)
2035 self.hideAfterResume()
2037 def hideAfterResume(self):
2038 if isinstance(self, InfoBarShowHide):
2041 def __getSeekable(self):
2042 service = self.session.nav.getCurrentService()
2045 return service.seek()
2047 def cueGetCurrentPosition(self):
2048 seek = self.__getSeekable()
2051 r = seek.getPlayPosition()
2056 def cueGetEndCutPosition(self):
2059 for cp in self.cut_list:
2060 if cp[1] == self.CUT_TYPE_OUT:
2064 elif cp[1] == self.CUT_TYPE_IN:
2068 def jumpPreviousNextMark(self, cmp, start=False):
2069 current_pos = self.cueGetCurrentPosition()
2070 if current_pos is None:
2072 mark = self.getNearestCutPoint(current_pos, cmp=cmp, start=start)
2073 if mark is not None:
2081 def jumpPreviousMark(self):
2082 # we add 2 seconds, so if the play position is <2s after
2083 # the mark, the mark before will be used
2084 self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True)
2086 def jumpNextMark(self):
2087 if not self.jumpPreviousNextMark(lambda x: x):
2090 def getNearestCutPoint(self, pts, cmp=abs, start=False):
2096 bestdiff = cmp(0 - pts)
2098 nearest = [0, False]
2099 for cp in self.cut_list:
2100 if beforecut and cp[1] in (self.CUT_TYPE_IN, self.CUT_TYPE_OUT):
2102 if cp[1] == self.CUT_TYPE_IN: # Start is here, disregard previous marks
2103 diff = cmp(cp[0] - pts)
2109 if cp[1] in (self.CUT_TYPE_MARK, self.CUT_TYPE_LAST):
2110 diff = cmp(cp[0] - pts)
2111 if diff >= 0 and (nearest is None or bestdiff > diff):
2116 def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000, onlyreturn=False):
2117 current_pos = self.cueGetCurrentPosition()
2118 if current_pos is None:
2119 print "not seekable"
2122 nearest_cutpoint = self.getNearestCutPoint(current_pos)
2124 if nearest_cutpoint is not None and abs(nearest_cutpoint[0] - current_pos) < tolerance:
2126 return nearest_cutpoint
2128 self.removeMark(nearest_cutpoint)
2129 elif not onlyremove and not onlyreturn:
2130 self.addMark((current_pos, self.CUT_TYPE_MARK))
2135 def addMark(self, point):
2136 insort(self.cut_list, point)
2137 self.uploadCuesheet()
2138 self.showAfterCuesheetOperation()
2140 def removeMark(self, point):
2141 self.cut_list.remove(point)
2142 self.uploadCuesheet()
2143 self.showAfterCuesheetOperation()
2145 def showAfterCuesheetOperation(self):
2146 if isinstance(self, InfoBarShowHide):
2149 def __getCuesheet(self):
2150 service = self.session.nav.getCurrentService()
2153 return service.cueSheet()
2155 def uploadCuesheet(self):
2156 cue = self.__getCuesheet()
2159 print "upload failed, no cuesheet interface"
2161 cue.setCutList(self.cut_list)
2163 def downloadCuesheet(self):
2164 cue = self.__getCuesheet()
2167 print "download failed, no cuesheet interface"
2170 self.cut_list = cue.getCutList()
2172 class InfoBarSummary(Screen):
2174 <screen position="0,0" size="132,64">
2175 <widget source="global.CurrentTime" render="Label" position="62,46" size="82,18" font="Regular;16" >
2176 <convert type="ClockToText">WithSeconds</convert>
2178 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="82,18" zPosition="1" >
2179 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
2180 <convert type="ConditionalShowHide">Blink</convert>
2182 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
2183 <convert type="ServiceName">Name</convert>
2185 <widget source="session.Event_Now" render="Progress" position="6,46" size="46,18" borderWidth="1" >
2186 <convert type="EventTime">Progress</convert>
2190 # for picon: (path="piconlcd" will use LCD picons)
2191 # <widget source="session.CurrentService" render="Picon" position="6,0" size="120,64" path="piconlcd" >
2192 # <convert type="ServiceName">Reference</convert>
2195 class InfoBarSummarySupport:
2199 def createSummary(self):
2200 return InfoBarSummary
2202 class InfoBarMoviePlayerSummary(Screen):
2204 <screen position="0,0" size="132,64">
2205 <widget source="global.CurrentTime" render="Label" position="62,46" size="64,18" font="Regular;16" halign="right" >
2206 <convert type="ClockToText">WithSeconds</convert>
2208 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="64,18" zPosition="1" >
2209 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
2210 <convert type="ConditionalShowHide">Blink</convert>
2212 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
2213 <convert type="ServiceName">Name</convert>
2215 <widget source="session.CurrentService" render="Progress" position="6,46" size="56,18" borderWidth="1" >
2216 <convert type="ServicePosition">Position</convert>
2220 class InfoBarMoviePlayerSummarySupport:
2224 def createSummary(self):
2225 return InfoBarMoviePlayerSummary
2227 class InfoBarTeletextPlugin:
2229 self.teletext_plugin = None
2231 for p in plugins.getPlugins(PluginDescriptor.WHERE_TELETEXT):
2232 self.teletext_plugin = p
2234 if self.teletext_plugin is not None:
2235 self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions",
2237 "startTeletext": (self.startTeletext, _("View teletext..."))
2240 print "no teletext plugin found!"
2242 def startTeletext(self):
2243 self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService())
2245 class InfoBarSubtitleSupport(object):
2247 object.__init__(self)
2248 self.subtitle_window = self.session.instantiateDialog(SubtitleDisplay)
2249 self.__subtitles_enabled = False
2251 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2253 iPlayableService.evEnd: self.__serviceStopped,
2254 iPlayableService.evUpdatedInfo: self.__updatedInfo
2256 self.cached_subtitle_checked = False
2257 self.__selected_subtitle = None
2259 def __serviceStopped(self):
2260 self.cached_subtitle_checked = False
2261 if self.__subtitles_enabled:
2262 self.subtitle_window.hide()
2263 self.__subtitles_enabled = False
2264 self.__selected_subtitle = None
2266 def __updatedInfo(self):
2267 if not self.cached_subtitle_checked:
2268 self.cached_subtitle_checked = True
2269 subtitle = self.getCurrentServiceSubtitle()
2270 self.setSelectedSubtitle(subtitle and subtitle.getCachedSubtitle())
2271 if self.__selected_subtitle:
2272 self.setSubtitlesEnable(True)
2274 def getCurrentServiceSubtitle(self):
2275 service = self.session.nav.getCurrentService()
2276 return service and service.subtitle()
2278 def setSubtitlesEnable(self, enable=True):
2279 subtitle = self.getCurrentServiceSubtitle()
2281 if self.__selected_subtitle:
2282 if subtitle and not self.__subtitles_enabled:
2283 subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
2284 self.subtitle_window.show()
2285 self.__subtitles_enabled = True
2288 subtitle.disableSubtitles(self.subtitle_window.instance)
2289 self.__selected_subtitle = False
2290 self.__subtitles_enabled = False
2291 self.subtitle_window.hide()
2293 def setSelectedSubtitle(self, subtitle):
2294 self.__selected_subtitle = subtitle
2296 subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable)
2297 selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle)
2299 class InfoBarServiceErrorPopupSupport:
2301 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2303 iPlayableService.evTuneFailed: self.__tuneFailed,
2304 iPlayableService.evStart: self.__serviceStarted
2306 self.__serviceStarted()
2308 def __serviceStarted(self):
2309 self.last_error = None
2310 Notifications.RemovePopup(id = "ZapError")
2312 def __tuneFailed(self):
2313 service = self.session.nav.getCurrentService()
2314 info = service and service.info()
2315 error = info and info.getInfo(iServiceInformation.sDVBState)
2317 if error == self.last_error:
2320 self.last_error = error
2323 eDVBServicePMTHandler.eventNoResources: _("No free tuner!"),
2324 eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"),
2325 eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"),
2326 eDVBServicePMTHandler.eventNoPATEntry: _("Service not found!\n(SID not found in PAT)"),
2327 eDVBServicePMTHandler.eventNoPMT: _("Service invalid!\n(Timeout reading PMT)"),
2328 eDVBServicePMTHandler.eventNewProgramInfo: None,
2329 eDVBServicePMTHandler.eventTuned: None,
2330 eDVBServicePMTHandler.eventSOF: None,
2331 eDVBServicePMTHandler.eventEOF: None,
2332 eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"),
2333 }.get(error) #this returns None when the key not exist in the dict
2335 if error is not None:
2336 Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError")
2338 Notifications.RemovePopup(id = "ZapError")