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 EpgSelection import EPGSelection
14 from Plugins.Plugin import PluginDescriptor
16 from Screen import Screen
17 from Screens.ChoiceBox import ChoiceBox
18 from Screens.Dish import Dish
19 from Screens.EventView import EventViewEPGSelect, EventViewSimple
20 from Screens.InputBox import InputBox
21 from Screens.MessageBox import MessageBox
22 from Screens.MinuteInput import MinuteInput
23 from Screens.TimerSelection import TimerSelection
24 from Screens.PictureInPicture import PictureInPicture
25 from Screens.SubtitleDisplay import SubtitleDisplay
26 from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
27 from Screens.SleepTimerEdit import SleepTimerEdit
28 from Screens.TimeDateInput import TimeDateInput
29 from ServiceReference import ServiceReference
31 from Tools import Notifications
32 from Tools.Directories import SCOPE_HDD, resolveFilename, pathExists
34 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
35 iPlayableService, eServiceReference, eEPGCache
37 from time import time, localtime, strftime
38 from os import stat as os_stat
39 from bisect import insort
41 from RecordTimer import RecordTimerEntry, RecordTimer
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.getroot()
352 assert menu.tag == "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)
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 "showEventInfoPlugin": (self.showEventInfoPlugins, _("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 showEventInfoPlugins(self):
494 for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO):
495 list.append((p.name, boundFunction(self.runPlugin, p)))
497 list.append((_("show single service EPG..."), self.openSingleServiceEPG))
498 self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list)
500 self.openSingleServiceEPG()
502 def runPlugin(self, plugin):
503 plugin(session = self.session, servicelist = self.servicelist)
505 def EventInfoPluginChosen(self, answer):
506 if answer is not None:
509 def openSimilarList(self, eventid, refstr):
510 self.session.open(EPGSelection, refstr, None, eventid)
512 def getNowNext(self):
514 service = self.session.nav.getCurrentService()
515 info = service and service.info()
516 ptr = info and info.getEvent(0)
518 self.epglist.append(ptr)
519 ptr = info and info.getEvent(1)
521 self.epglist.append(ptr)
523 def __evEventInfoChanged(self):
524 if self.is_now_next and len(self.dlg_stack) == 1:
526 assert self.eventView
527 if len(self.epglist):
528 self.eventView.setEvent(self.epglist[0])
530 def openEventView(self):
531 ref = self.session.nav.getCurrentlyPlayingServiceReference()
533 if len(self.epglist) == 0:
534 self.is_now_next = False
535 epg = eEPGCache.getInstance()
536 ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1)
538 self.epglist.append(ptr)
539 ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1)
541 self.epglist.append(ptr)
543 self.is_now_next = True
544 if len(self.epglist) > 0:
545 self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)
546 self.dlg_stack.append(self.eventView)
548 print "no epg for the service avail.. so we show multiepg instead of eventinfo"
549 self.openMultiServiceEPG(False)
551 def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
552 if len(self.epglist) > 1:
553 tmp = self.epglist[0]
554 self.epglist[0]=self.epglist[1]
556 setEvent(self.epglist[0])
558 class InfoBarRdsDecoder:
559 """provides RDS and Rass support/display"""
561 self.rds_display = self.session.instantiateDialog(RdsInfoDisplay)
562 self.rass_interactive = None
564 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
566 iPlayableService.evEnd: self.__serviceStopped,
567 iPlayableService.evUpdatedRassSlidePic: self.RassSlidePicChanged
570 self["RdsActions"] = ActionMap(["InfobarRdsActions"],
572 "startRassInteractive": self.startRassInteractive
575 self["RdsActions"].setEnabled(False)
577 self.onLayoutFinish.append(self.rds_display.show)
578 self.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
580 def RassInteractivePossibilityChanged(self, state):
581 self["RdsActions"].setEnabled(state)
583 def RassSlidePicChanged(self):
584 if not self.rass_interactive:
585 service = self.session.nav.getCurrentService()
586 decoder = service and service.rdsDecoder()
588 decoder.showRassSlidePicture()
590 def __serviceStopped(self):
591 if self.rass_interactive is not None:
592 rass_interactive = self.rass_interactive
593 self.rass_interactive = None
594 rass_interactive.close()
596 def startRassInteractive(self):
597 self.rds_display.hide()
598 self.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
600 def RassInteractiveClosed(self, *val):
601 if self.rass_interactive is not None:
602 self.rass_interactive = None
603 self.RassSlidePicChanged()
604 self.rds_display.show()
607 """handles actions like seeking, pause"""
609 SEEK_STATE_PLAY = (0, 0, 0, ">")
610 SEEK_STATE_PAUSE = (1, 0, 0, "||")
611 SEEK_STATE_EOF = (1, 0, 0, "END")
613 def __init__(self, actionmap = "InfobarSeekActions", useSeekBackHack=True):
614 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
616 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
617 iPlayableService.evStart: self.__serviceStarted,
619 iPlayableService.evEOF: self.__evEOF,
620 iPlayableService.evSOF: self.__evSOF,
623 self.eofTimer = eTimer()
624 self.eofTimer.timeout.get().append(self.doEof)
625 self.eofInhibitTimer = eTimer()
626 self.eofInhibitTimer.timeout.get().append(self.inhibitEof)
628 self.minSpeedBackward = useSeekBackHack and 16 or 0
630 class InfoBarSeekActionMap(HelpableActionMap):
631 def __init__(self, screen, *args, **kwargs):
632 HelpableActionMap.__init__(self, screen, *args, **kwargs)
635 def action(self, contexts, action):
636 print "action:", action
637 if action[:5] == "seek:":
638 time = int(action[5:])
639 self.screen.doSeekRelative(time * 90000)
641 elif action[:8] == "seekdef:":
642 key = int(action[8:])
643 time = [-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value,
644 -config.seek.selfdefined_46.value, False, config.seek.selfdefined_46.value,
645 -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value][key-1]
646 self.screen.doSeekRelative(time * 90000)
649 return HelpableActionMap.action(self, contexts, action)
651 self["SeekActions"] = InfoBarSeekActionMap(self, actionmap,
653 "playpauseService": self.playpauseService,
654 "pauseService": (self.pauseService, _("pause")),
655 "unPauseService": (self.unPauseService, _("continue")),
657 "seekFwd": (self.seekFwd, _("skip forward")),
658 "seekFwdManual": (self.seekFwdManual, _("skip forward (enter time)")),
659 "seekBack": (self.seekBack, _("skip backward")),
660 "seekBackManual": (self.seekBackManual, _("skip backward (enter time)"))
662 # give them a little more priority to win over color buttons
664 self["SeekActions"].setEnabled(False)
666 self.seekstate = self.SEEK_STATE_PLAY
667 self.lastseekstate = self.SEEK_STATE_PLAY
669 self.onPlayStateChanged = [ ]
671 self.lockedBecauseOfSkipping = False
673 self.__seekableStatusChanged()
675 def makeStateForward(self, n):
676 minspeed = config.seek.stepwise_minspeed.value
677 repeat = int(config.seek.stepwise_repeat.value)
678 if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
679 return (0, n * repeat, repeat, ">> %dx" % n)
681 return (0, n, 0, ">> %dx" % n)
683 def makeStateBackward(self, n):
684 minspeed = config.seek.stepwise_minspeed.value
685 repeat = int(config.seek.stepwise_repeat.value)
686 if self.minSpeedBackward and n < self.minSpeedBackward:
687 r = (self.minSpeedBackward - 1)/ n + 1
688 if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
690 return (0, -n * r, r, "<< %dx" % n)
691 elif minspeed != "Never" and n >= int(minspeed) and repeat > 1:
692 return (0, -n * repeat, repeat, "<< %dx" % n)
694 return (0, -n, 0, "<< %dx" % n)
696 def makeStateSlowMotion(self, n):
697 return (0, 0, n, "/%d" % n)
699 def isStateForward(self, state):
702 def isStateBackward(self, state):
705 def isStateSlowMotion(self, state):
706 return state[1] == 0 and state[2] > 1
708 def getHigher(self, n, lst):
714 def getLower(self, n, lst):
722 def showAfterSeek(self):
723 if isinstance(self, InfoBarShowHide):
733 service = self.session.nav.getCurrentService()
737 seek = service.seek()
739 if seek is None or not seek.isCurrentlySeekable():
744 def isSeekable(self):
745 if self.getSeek() is None:
749 def __seekableStatusChanged(self):
750 # print "seekable status changed!"
751 if not self.isSeekable():
752 self["SeekActions"].setEnabled(False)
753 # print "not seekable, return to play"
754 self.setSeekState(self.SEEK_STATE_PLAY)
756 self["SeekActions"].setEnabled(True)
759 def __serviceStarted(self):
760 self.seekstate = self.SEEK_STATE_PLAY
761 self.__seekableStatusChanged()
762 if self.eofState != 0:
766 def setSeekState(self, state):
767 service = self.session.nav.getCurrentService()
772 if not self.isSeekable():
773 if state not in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
774 state = self.SEEK_STATE_PLAY
776 pauseable = service.pause()
778 if pauseable is None:
779 print "not pauseable."
780 state = self.SEEK_STATE_PLAY
782 oldstate = self.seekstate
783 self.seekstate = state
786 if oldstate[i] != self.seekstate[i]:
787 (self.session.nav.pause, pauseable.setFastForward, pauseable.setSlowMotion)[i](self.seekstate[i])
789 for c in self.onPlayStateChanged:
792 self.checkSkipShowHideLock()
796 def playpauseService(self):
797 if self.seekstate != self.SEEK_STATE_PLAY:
798 self.unPauseService()
802 def pauseService(self):
803 if self.seekstate == self.SEEK_STATE_PAUSE:
804 if config.seek.on_pause.value == "play":
805 self.unPauseService()
806 elif config.seek.on_pause.value == "step":
807 self.doSeekRelative(0)
808 elif config.seek.on_pause.value == "last":
809 self.setSeekState(self.lastseekstate)
810 self.lastseekstate = self.SEEK_STATE_PLAY
812 if self.seekstate != self.SEEK_STATE_EOF:
813 self.lastseekstate = self.seekstate
814 self.setSeekState(self.SEEK_STATE_PAUSE);
816 def unPauseService(self):
818 if self.seekstate == self.SEEK_STATE_PLAY:
820 self.setSeekState(self.SEEK_STATE_PLAY)
822 def doSeek(self, pts):
823 seekable = self.getSeek()
826 prevstate = self.seekstate
827 if self.eofState == 1:
830 if self.seekstate == self.SEEK_STATE_EOF:
831 if prevstate == self.SEEK_STATE_PAUSE:
832 self.setSeekState(self.SEEK_STATE_PAUSE)
834 self.setSeekState(self.SEEK_STATE_PLAY)
835 self.eofInhibitTimer.start(200, True)
838 def doSeekRelative(self, pts):
839 seekable = self.getSeek()
842 prevstate = self.seekstate
843 if self.eofState == 1:
846 if self.seekstate == self.SEEK_STATE_EOF:
847 if prevstate == self.SEEK_STATE_PAUSE:
848 self.setSeekState(self.SEEK_STATE_PAUSE)
850 self.setSeekState(self.SEEK_STATE_PLAY)
851 self.eofInhibitTimer.start(200, True)
852 seekable.seekRelative(pts<0 and -1 or 1, abs(pts))
853 if abs(pts) > 100 and config.usage.show_infobar_on_skip.value:
857 if self.seekstate == self.SEEK_STATE_PLAY:
858 self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
859 elif self.seekstate == self.SEEK_STATE_PAUSE:
860 if len(config.seek.speeds_slowmotion.value):
861 self.setSeekState(self.makeStateSlowMotion(config.seek.speeds_slowmotion.value[-1]))
863 self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value)))
864 elif self.seekstate == self.SEEK_STATE_EOF:
866 elif self.isStateForward(self.seekstate):
867 speed = self.seekstate[1]
868 if self.seekstate[2]:
869 speed /= self.seekstate[2]
870 speed = self.getHigher(speed, config.seek.speeds_forward.value) or config.seek.speeds_forward.value[-1]
871 self.setSeekState(self.makeStateForward(speed))
872 elif self.isStateBackward(self.seekstate):
873 speed = -self.seekstate[1]
874 if self.seekstate[2]:
875 speed /= self.seekstate[2]
876 speed = self.getLower(speed, config.seek.speeds_backward.value)
878 self.setSeekState(self.makeStateBackward(speed))
880 self.setSeekState(self.SEEK_STATE_PLAY)
881 elif self.isStateSlowMotion(self.seekstate):
882 speed = self.getLower(self.seekstate[2], config.seek.speeds_slowmotion.value) or config.seek.speeds_slowmotion.value[0]
883 self.setSeekState(self.makeStateSlowMotion(speed))
886 if self.seekstate == self.SEEK_STATE_PLAY:
887 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
888 elif self.seekstate == self.SEEK_STATE_EOF:
889 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
890 self.doSeekRelative(-6)
891 elif self.seekstate == self.SEEK_STATE_PAUSE:
892 self.doSeekRelative(-3)
893 elif self.isStateForward(self.seekstate):
894 speed = self.seekstate[1]
895 if self.seekstate[2]:
896 speed /= self.seekstate[2]
897 speed = self.getLower(speed, config.seek.speeds_forward.value)
899 self.setSeekState(self.makeStateForward(speed))
901 self.setSeekState(self.SEEK_STATE_PLAY)
902 elif self.isStateBackward(self.seekstate):
903 speed = -self.seekstate[1]
904 if self.seekstate[2]:
905 speed /= self.seekstate[2]
906 speed = self.getHigher(speed, config.seek.speeds_backward.value) or config.seek.speeds_backward.value[-1]
907 self.setSeekState(self.makeStateBackward(speed))
908 elif self.isStateSlowMotion(self.seekstate):
909 speed = self.getHigher(self.seekstate[2], config.seek.speeds_slowmotion.value)
911 self.setSeekState(self.makeStateSlowMotion(speed))
913 self.setSeekState(self.SEEK_STATE_PAUSE)
915 def seekFwdManual(self):
916 self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
918 def fwdSeekTo(self, minutes):
919 print "Seek", minutes, "minutes forward"
920 self.doSeekRelative(minutes * 60 * 90000)
922 def seekBackManual(self):
923 self.session.openWithCallback(self.rwdSeekTo, MinuteInput)
925 def rwdSeekTo(self, minutes):
927 self.doSeekRelative(-minutes * 60 * 90000)
929 def checkSkipShowHideLock(self):
930 wantlock = self.seekstate != self.SEEK_STATE_PLAY
932 if config.usage.show_infobar_on_skip.value:
933 if self.lockedBecauseOfSkipping and not wantlock:
935 self.lockedBecauseOfSkipping = False
937 if wantlock and not self.lockedBecauseOfSkipping:
939 self.lockedBecauseOfSkipping = True
941 def calcRemainingTime(self):
942 seekable = self.getSeek()
943 if seekable is not None:
944 len = seekable.getLength()
946 tmp = self.cueGetEndCutPosition()
951 pos = seekable.getPlayPosition()
952 speednom = self.seekstate[1] or 1
953 speedden = self.seekstate[2] or 1
954 if not len[0] and not pos[0]:
957 time = (len[1] - pos[1])*speedden/(90*speednom)
962 if self.eofState == 0 and self.seekstate != self.SEEK_STATE_EOF:
964 time = self.calcRemainingTime()
966 time = 3000 # Failed to calc, use default
968 time = 300 # Passed end, shortest wait
970 self.eofState = -2 # Too long, block eof
973 time += 1000 # Add margin
974 self.eofTimer.start(time, True)
976 def inhibitEof(self):
977 if self.eofState >= 1:
978 self.eofState = -self.eofState
983 if self.seekstate == self.SEEK_STATE_EOF:
985 if self.eofState == -2 or self.isStateBackward(self.seekstate):
989 # if we are seeking, we try to end up ~1s before the end, and pause there.
990 eofstate = self.eofState
991 seekstate = self.seekstate
993 if not self.seekstate == self.SEEK_STATE_PAUSE:
994 self.setSeekState(self.SEEK_STATE_EOF)
995 if eofstate == -1 or not seekstate in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
996 seekable = self.getSeek()
997 if seekable is not None:
999 if eofstate == 1 and seekstate == self.SEEK_STATE_PLAY:
1000 self.doEofInternal(True)
1002 self.doEofInternal(False)
1004 def doEofInternal(self, playing):
1005 pass # Defined in subclasses
1008 self.setSeekState(self.SEEK_STATE_PLAY)
1011 from Screens.PVRState import PVRState, TimeshiftState
1013 class InfoBarPVRState:
1014 def __init__(self, screen=PVRState):
1015 self.onPlayStateChanged.append(self.__playStateChanged)
1016 self.pvrStateDialog = self.session.instantiateDialog(screen)
1017 self.onShow.append(self._mayShow)
1018 self.onHide.append(self.pvrStateDialog.hide)
1021 if self.execing and self.seekstate != self.SEEK_STATE_PLAY:
1022 self.pvrStateDialog.show()
1024 def __playStateChanged(self, state):
1025 playstateString = state[3]
1026 self.pvrStateDialog["state"].setText(playstateString)
1029 class InfoBarTimeshiftState(InfoBarPVRState):
1031 InfoBarPVRState.__init__(self, screen=TimeshiftState)
1034 if self.execing and self.timeshift_enabled and self.seekstate != self.SEEK_STATE_PLAY:
1035 self.pvrStateDialog.show()
1037 class InfoBarShowMovies:
1039 # i don't really like this class.
1040 # it calls a not further specified "movie list" on up/down/movieList,
1041 # so this is not more than an action map
1043 self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions",
1045 "movieList": (self.showMovies, _("movie list")),
1046 "up": (self.showMovies, _("movie list")),
1047 "down": (self.showMovies, _("movie list"))
1050 # InfoBarTimeshift requires InfoBarSeek, instantiated BEFORE!
1054 # Timeshift works the following way:
1055 # demux0 demux1 "TimeshiftActions" "TimeshiftActivateActions" "SeekActions"
1056 # - normal playback TUNER unused PLAY enable disable disable
1057 # - user presses "yellow" button. FILE record PAUSE enable disable enable
1058 # - user presess pause again FILE record PLAY enable disable enable
1059 # - user fast forwards FILE record FF enable disable enable
1060 # - end of timeshift buffer reached TUNER record PLAY enable enable disable
1061 # - user backwards FILE record BACK # !! enable disable enable
1065 # - when a service is playing, pressing the "timeshiftStart" button ("yellow") enables recording ("enables timeshift"),
1066 # freezes the picture (to indicate timeshift), sets timeshiftMode ("activates timeshift")
1067 # now, the service becomes seekable, so "SeekActions" are enabled, "TimeshiftEnableActions" are disabled.
1068 # - the user can now PVR around
1069 # - if it hits the end, the service goes into live mode ("deactivates timeshift", it's of course still "enabled")
1070 # the service looses it's "seekable" state. It can still be paused, but just to activate timeshift right
1072 # the seek actions will be disabled, but the timeshiftActivateActions will be enabled
1073 # - if the user rewinds, or press pause, timeshift will be activated again
1075 # note that a timeshift can be enabled ("recording") and
1076 # activated (currently time-shifting).
1078 class InfoBarTimeshift:
1080 self["TimeshiftActions"] = HelpableActionMap(self, "InfobarTimeshiftActions",
1082 "timeshiftStart": (self.startTimeshift, _("start timeshift")), # the "yellow key"
1083 "timeshiftStop": (self.stopTimeshift, _("stop timeshift")) # currently undefined :), probably 'TV'
1085 self["TimeshiftActivateActions"] = ActionMap(["InfobarTimeshiftActivateActions"],
1087 "timeshiftActivateEnd": self.activateTimeshiftEnd, # something like "rewind key"
1088 "timeshiftActivateEndAndPause": self.activateTimeshiftEndAndPause # something like "pause key"
1089 }, prio=-1) # priority over record
1091 self.timeshift_enabled = 0
1092 self.timeshift_state = 0
1093 self.ts_rewind_timer = eTimer()
1094 self.ts_rewind_timer.callback.append(self.rewindService)
1096 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1098 iPlayableService.evStart: self.__serviceStarted,
1099 iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged
1102 def getTimeshift(self):
1103 service = self.session.nav.getCurrentService()
1104 return service and service.timeshift()
1106 def startTimeshift(self):
1107 print "enable timeshift"
1108 ts = self.getTimeshift()
1110 self.session.open(MessageBox, _("Timeshift not possible!"), MessageBox.TYPE_ERROR)
1111 print "no ts interface"
1114 if self.timeshift_enabled:
1115 print "hu, timeshift already enabled?"
1117 if not ts.startTimeshift():
1118 self.timeshift_enabled = 1
1120 # we remove the "relative time" for now.
1121 #self.pvrStateDialog["timeshift"].setRelative(time.time())
1124 #self.setSeekState(self.SEEK_STATE_PAUSE)
1125 self.activateTimeshiftEnd(False)
1127 # enable the "TimeshiftEnableActions", which will override
1128 # the startTimeshift actions
1129 self.__seekableStatusChanged()
1131 print "timeshift failed"
1133 def stopTimeshift(self):
1134 if not self.timeshift_enabled:
1136 print "disable timeshift"
1137 ts = self.getTimeshift()
1140 self.session.openWithCallback(self.stopTimeshiftConfirmed, MessageBox, _("Stop Timeshift?"), MessageBox.TYPE_YESNO)
1142 def stopTimeshiftConfirmed(self, confirmed):
1146 ts = self.getTimeshift()
1151 self.timeshift_enabled = 0
1154 self.__seekableStatusChanged()
1156 # activates timeshift, and seeks to (almost) the end
1157 def activateTimeshiftEnd(self, back = True):
1158 ts = self.getTimeshift()
1159 print "activateTimeshiftEnd"
1164 if ts.isTimeshiftActive():
1165 print "!! activate timeshift called - but shouldn't this be a normal pause?"
1169 ts.activateTimeshift() # activate timeshift will automatically pause
1170 self.setSeekState(self.SEEK_STATE_PAUSE)
1173 self.doSeek(-5) # seek some gops before end
1174 self.ts_rewind_timer.start(200, 1)
1176 self.doSeek(-1) # seek 1 gop before end
1178 def rewindService(self):
1179 self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
1181 # same as activateTimeshiftEnd, but pauses afterwards.
1182 def activateTimeshiftEndAndPause(self):
1183 print "activateTimeshiftEndAndPause"
1184 #state = self.seekstate
1185 self.activateTimeshiftEnd(False)
1187 def __seekableStatusChanged(self):
1190 # print "self.isSeekable", self.isSeekable()
1191 # print "self.timeshift_enabled", self.timeshift_enabled
1193 # when this service is not seekable, but timeshift
1194 # is enabled, this means we can activate
1196 if not self.isSeekable() and self.timeshift_enabled:
1199 # print "timeshift activate:", enabled
1200 self["TimeshiftActivateActions"].setEnabled(enabled)
1202 def __serviceStarted(self):
1203 self.timeshift_enabled = False
1204 self.__seekableStatusChanged()
1206 from Screens.PiPSetup import PiPSetup
1208 class InfoBarExtensions:
1209 EXTENSION_SINGLE = 0
1215 self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
1217 "extensions": (self.showExtensionSelection, _("view extensions...")),
1220 def addExtension(self, extension, key = None, type = EXTENSION_SINGLE):
1221 self.list.append((type, extension, key))
1223 def updateExtension(self, extension, key = None):
1224 self.extensionsList.append(extension)
1226 if self.extensionKeys.has_key(key):
1230 for x in self.availableKeys:
1231 if not self.extensionKeys.has_key(x):
1236 self.extensionKeys[key] = len(self.extensionsList) - 1
1238 def updateExtensions(self):
1239 self.extensionsList = []
1240 self.availableKeys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ]
1241 self.extensionKeys = {}
1243 if x[0] == self.EXTENSION_SINGLE:
1244 self.updateExtension(x[1], x[2])
1247 self.updateExtension(y[0], y[1])
1250 def showExtensionSelection(self):
1251 self.updateExtensions()
1252 extensionsList = self.extensionsList[:]
1255 for x in self.availableKeys:
1256 if self.extensionKeys.has_key(x):
1257 entry = self.extensionKeys[x]
1258 extension = self.extensionsList[entry]
1260 name = str(extension[0]())
1261 list.append((extension[0](), extension))
1263 extensionsList.remove(extension)
1265 extensionsList.remove(extension)
1266 for x in extensionsList:
1267 list.append((x[0](), x))
1268 keys += [""] * len(extensionsList)
1269 self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys)
1271 def extensionCallback(self, answer):
1272 if answer is not None:
1275 from Tools.BoundFunction import boundFunction
1277 # depends on InfoBarExtensions
1279 class InfoBarPlugins:
1281 self.addExtension(extension = self.getPluginList, type = InfoBarExtensions.EXTENSION_LIST)
1283 def getPluginName(self, name):
1286 def getPluginList(self):
1288 for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
1289 list.append(((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None))
1292 def runPlugin(self, plugin):
1293 plugin(session = self.session, servicelist = self.servicelist)
1295 from Components.Task import job_manager
1296 class InfoBarJobman:
1298 self.addExtension(extension = self.getJobList, type = InfoBarExtensions.EXTENSION_LIST)
1300 def getJobList(self):
1302 for job in job_manager.getPendingJobs():
1303 list.append(((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None))
1306 def getJobName(self, job):
1307 return "%s: %s (%d%%)" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end)))
1309 def showJobView(self, job):
1310 from Screens.TaskView import JobView
1311 job_manager.in_background = False
1312 self.session.openWithCallback(self.JobViewCB, JobView, job)
1314 def JobViewCB(self, in_background):
1315 job_manager.in_background = in_background
1317 # depends on InfoBarExtensions
1318 class InfoBarSleepTimer:
1320 self.addExtension((self.getSleepTimerName, self.showSleepTimerSetup, lambda: True), "1")
1322 def getSleepTimerName(self):
1323 return _("Sleep Timer")
1325 def showSleepTimerSetup(self):
1326 self.session.open(SleepTimerEdit)
1328 # depends on InfoBarExtensions
1331 self.session.pipshown = False
1332 if SystemInfo.get("NumVideoDecoders", 1) > 1:
1333 self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
1334 self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
1335 self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
1338 return self.session.pipshown
1340 def pipHandles0Action(self):
1341 return self.pipShown() and config.usage.pip_zero_button.value != "standard"
1343 def getShowHideName(self):
1344 if self.session.pipshown:
1345 return _("Disable Picture in Picture")
1347 return _("Activate Picture in Picture")
1349 def getSwapName(self):
1350 return _("Swap Services")
1352 def getMoveName(self):
1353 return _("Move Picture in Picture")
1356 if self.session.pipshown:
1357 del self.session.pip
1358 self.session.pipshown = False
1360 self.session.pip = self.session.instantiateDialog(PictureInPicture)
1361 self.session.pip.show()
1362 newservice = self.session.nav.getCurrentlyPlayingServiceReference()
1363 if self.session.pip.playService(newservice):
1364 self.session.pipshown = True
1365 self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
1367 self.session.pipshown = False
1368 del self.session.pip
1369 self.session.nav.playService(newservice)
1372 swapservice = self.session.nav.getCurrentlyPlayingServiceReference()
1373 if self.session.pip.servicePath:
1374 servicepath = self.servicelist.getCurrentServicePath()
1375 ref=servicepath[len(servicepath)-1]
1376 pipref=self.session.pip.getCurrentService()
1377 self.session.pip.playService(swapservice)
1378 self.servicelist.setCurrentServicePath(self.session.pip.servicePath)
1379 if pipref.toString() != ref.toString(): # is a subservice ?
1380 self.session.nav.stopService() # stop portal
1381 self.session.nav.playService(pipref) # start subservice
1382 self.session.pip.servicePath=servicepath
1385 self.session.open(PiPSetup, pip = self.session.pip)
1387 def pipDoHandle0Action(self):
1388 use = config.usage.pip_zero_button.value
1391 elif "swapstop" == use:
1397 from RecordTimer import parseEvent, RecordTimerEntry
1399 class InfoBarInstantRecord:
1400 """Instant Record - handles the instantRecord action in order to
1401 start/stop instant records"""
1403 self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
1405 "instantRecord": (self.instantRecord, _("Instant Record...")),
1409 def stopCurrentRecording(self, entry = -1):
1410 if entry is not None and entry != -1:
1411 self.session.nav.RecordTimer.removeEntry(self.recording[entry])
1412 self.recording.remove(self.recording[entry])
1414 def startInstantRecording(self, limitEvent = False):
1415 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
1417 # try to get event info
1420 service = self.session.nav.getCurrentService()
1421 epg = eEPGCache.getInstance()
1422 event = epg.lookupEventTime(serviceref, -1, 0)
1424 info = service.info()
1425 ev = info.getEvent(0)
1431 end = begin + 3600 # dummy
1432 name = "instant record"
1436 if event is not None:
1437 curEvent = parseEvent(event)
1439 description = curEvent[3]
1440 eventid = curEvent[4]
1445 self.session.open(MessageBox, _("No event info found, recording indefinitely."), MessageBox.TYPE_INFO)
1447 if isinstance(serviceref, eServiceReference):
1448 serviceref = ServiceReference(serviceref)
1450 recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = config.movielist.last_videodir.value)
1451 recording.dontSave = True
1453 if event is None or limitEvent == False:
1454 recording.autoincrease = True
1455 if recording.setAutoincreaseEnd():
1456 self.session.nav.RecordTimer.record(recording)
1457 self.recording.append(recording)
1459 simulTimerList = self.session.nav.RecordTimer.record(recording)
1460 if simulTimerList is not None: # conflict with other recording
1461 name = simulTimerList[1].name
1462 name_date = name + strftime(" %c", localtime(simulTimerList[1].begin))
1463 print "[TIMER] conflicts with", name_date
1464 recording.autoincrease = True # start with max available length, then increment
1465 if recording.setAutoincreaseEnd():
1466 self.session.nav.RecordTimer.record(recording)
1467 self.recording.append(recording)
1468 self.session.open(MessageBox, _("Record time limited due to conflicting timer %s" % name_date), MessageBox.TYPE_INFO)
1470 self.session.open(MessageBox, _("Couldn't record due to conflicting timer %s" % name), MessageBox.TYPE_INFO)
1471 recording.autoincrease = False
1473 self.recording.append(recording)
1475 def isInstantRecordRunning(self):
1476 print "self.recording:", self.recording
1477 if len(self.recording) > 0:
1478 for x in self.recording:
1483 def recordQuestionCallback(self, answer):
1484 print "pre:\n", self.recording
1486 if answer is None or answer[1] == "no":
1489 recording = self.recording[:]
1491 if not x in self.session.nav.RecordTimer.timer_list:
1492 self.recording.remove(x)
1493 elif x.dontSave and x.isRunning():
1494 list.append((x, False))
1496 if answer[1] == "changeduration":
1497 if len(self.recording) == 1:
1498 self.changeDuration(0)
1500 self.session.openWithCallback(self.changeDuration, TimerSelection, list)
1501 elif answer[1] == "changeendtime":
1502 if len(self.recording) == 1:
1505 self.session.openWithCallback(self.setEndtime, TimerSelection, list)
1506 elif answer[1] == "stop":
1507 if len(self.recording) == 1:
1508 self.stopCurrentRecording(0)
1510 self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
1511 elif answer[1] in ( "indefinitely" , "manualduration", "manualendtime", "event"):
1512 self.startInstantRecording(limitEvent = answer[1] in ("event", "manualendtime") or False)
1513 if answer[1] == "manualduration":
1514 self.changeDuration(len(self.recording)-1)
1515 elif answer[1] == "manualendtime":
1516 self.setEndtime(len(self.recording)-1)
1517 print "after:\n", self.recording
1519 def setEndtime(self, entry):
1520 if entry is not None:
1521 self.selectedEntry = entry
1522 self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end)
1523 dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime)
1524 dlg.setTitle(_("Please change recording endtime"))
1526 def TimeDateInputClosed(self, ret):
1529 localendtime = localtime(ret[1])
1530 print "stopping recording at", strftime("%c", localendtime)
1531 if self.recording[self.selectedEntry].end != ret[1]:
1532 self.recording[self.selectedEntry].autoincrease = False
1533 self.recording[self.selectedEntry].end = ret[1]
1534 self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
1536 def changeDuration(self, entry):
1537 if entry is not None:
1538 self.selectedEntry = entry
1539 self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5", maxSize=False, type=Input.NUMBER)
1541 def inputCallback(self, value):
1542 if value is not None:
1543 print "stopping recording after", int(value), "minutes."
1545 self.recording[self.selectedEntry].autoincrease = False
1546 self.recording[self.selectedEntry].end = int(time()) + 60 * int(value)
1547 self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry])
1549 def instantRecord(self):
1550 dir = config.movielist.last_videodir.value
1551 if not pathExists(dir):
1552 dir = resolveFilename(SCOPE_HDD)
1556 # XXX: this message is a little odd as we might be recording to a remote device
1557 self.session.open(MessageBox, _("No HDD found or HDD not initialized!"), MessageBox.TYPE_ERROR)
1560 if self.isInstantRecordRunning():
1561 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1562 title=_("A recording is currently running.\nWhat do you want to do?"), \
1563 list=[(_("stop recording"), "stop"), \
1564 (_("change recording (duration)"), "changeduration"), \
1565 (_("change recording (endtime)"), "changeendtime"), \
1566 (_("add recording (indefinitely)"), "indefinitely"), \
1567 (_("add recording (stop after current event)"), "event"), \
1568 (_("add recording (enter recording duration)"), "manualduration"), \
1569 (_("add recording (enter recording endtime)"), "manualendtime"), \
1570 (_("do nothing"), "no")])
1572 self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
1573 title=_("Start recording?"), \
1574 list=[(_("add recording (indefinitely)"), "indefinitely"), \
1575 (_("add recording (stop after current event)"), "event"), \
1576 (_("add recording (enter recording duration)"), "manualduration"), \
1577 (_("add recording (enter recording endtime)"), "manualendtime"), \
1578 (_("don't record"), "no")])
1580 from Tools.ISO639 import LanguageCodes
1582 class InfoBarAudioSelection:
1584 self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
1586 "audioSelection": (self.audioSelection, _("Audio Options...")),
1589 def audioSelection(self):
1590 service = self.session.nav.getCurrentService()
1591 self.audioTracks = audio = service and service.audioTracks()
1592 n = audio and audio.getNumberOfTracks() or 0
1595 self.audioChannel = service.audioChannel()
1598 i = audio.getTrackInfo(x)
1599 language = i.getLanguage()
1600 description = i.getDescription()
1602 if LanguageCodes.has_key(language):
1603 language = LanguageCodes[language][0]
1605 if len(description):
1606 description += " (" + language + ")"
1608 description = language
1610 tlist.append((description, x))
1612 tlist.sort(key=lambda x: x[0])
1614 selectedAudio = self.audioTracks.getCurrentTrack()
1619 if x[1] != selectedAudio:
1624 if SystemInfo["CanDownmixAC3"]:
1625 tlist = [(_("AC3 downmix") + " - " +[_("Off"), _("On")][config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix),
1626 ([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"),
1628 keys = [ "red", "green", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
1631 tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
1632 keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
1634 self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys)
1636 del self.audioTracks
1638 def changeAC3Downmix(self, arg):
1639 choicelist = self.session.current_dialog["list"]
1640 list = choicelist.list
1642 list[0][1]=(t[0], t[1], t[2], t[3], t[4], t[5], t[6],
1643 _("AC3 downmix") + " - " +[_("On"), _("Off")][config.av.downmix_ac3.value and 1 or 0])
1644 choicelist.setList(list)
1645 if config.av.downmix_ac3.value:
1646 config.av.downmix_ac3.value = False
1648 config.av.downmix_ac3.value = True
1649 config.av.downmix_ac3.save()
1651 def audioSelected(self, audio):
1652 if audio is not None:
1653 if isinstance(audio[1], str):
1654 if audio[1] == "mode":
1655 keys = ["red", "green", "yellow"]
1656 selection = self.audioChannel.getCurrentChannel()
1657 tlist = [(_("left"), 0), (_("stereo"), 1), (_("right"), 2)]
1658 self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys)
1660 del self.audioChannel
1661 if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]:
1662 self.audioTracks.selectTrack(audio[1])
1664 del self.audioChannel
1665 del self.audioTracks
1667 def modeSelected(self, mode):
1668 if mode is not None:
1669 self.audioChannel.selectChannel(mode[1])
1670 del self.audioChannel
1672 class InfoBarSubserviceSelection:
1674 self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",
1676 "subserviceSelection": (self.subserviceSelection, _("Subservice list...")),
1679 self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions",
1681 "nextSubservice": (self.nextSubservice, _("Switch to next subservice")),
1682 "prevSubservice": (self.prevSubservice, _("Switch to previous subservice"))
1684 self["SubserviceQuickzapAction"].setEnabled(False)
1686 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1688 iPlayableService.evUpdatedEventInfo: self.checkSubservicesAvail
1693 def checkSubservicesAvail(self):
1694 service = self.session.nav.getCurrentService()
1695 subservices = service and service.subServices()
1696 if not subservices or subservices.getNumberOfSubservices() == 0:
1697 self["SubserviceQuickzapAction"].setEnabled(False)
1699 def nextSubservice(self):
1700 self.changeSubservice(+1)
1702 def prevSubservice(self):
1703 self.changeSubservice(-1)
1705 def changeSubservice(self, direction):
1706 service = self.session.nav.getCurrentService()
1707 subservices = service and service.subServices()
1708 n = subservices and subservices.getNumberOfSubservices()
1711 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1713 if subservices.getSubservice(x).toString() == ref.toString():
1716 selection += direction
1721 newservice = subservices.getSubservice(selection)
1722 if newservice.valid():
1725 self.session.nav.playService(newservice, False)
1727 def subserviceSelection(self):
1728 service = self.session.nav.getCurrentService()
1729 subservices = service and service.subServices()
1730 self.bouquets = self.servicelist.getBouquetList()
1731 n = subservices and subservices.getNumberOfSubservices()
1734 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1737 i = subservices.getSubservice(x)
1738 if i.toString() == ref.toString():
1740 tlist.append((i.getName(), i))
1742 if self.bouquets and len(self.bouquets):
1743 keys = ["red", "blue", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1744 if config.usage.multibouquet.value:
1745 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to bouquet"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1747 tlist = [(_("Quickzap"), "quickzap", service.subServices()), (_("Add to favourites"), "CALLFUNC", self.addSubserviceToBouquetCallback), ("--", "")] + tlist
1750 tlist = [(_("Quickzap"), "quickzap", service.subServices()), ("--", "")] + tlist
1751 keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
1754 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys)
1756 def subserviceSelected(self, service):
1758 if not service is None:
1759 if isinstance(service[1], str):
1760 if service[1] == "quickzap":
1761 from Screens.SubservicesQuickzap import SubservicesQuickzap
1762 self.session.open(SubservicesQuickzap, service[2])
1764 self["SubserviceQuickzapAction"].setEnabled(True)
1765 self.session.nav.playService(service[1], False)
1767 def addSubserviceToBouquetCallback(self, service):
1768 if len(service) > 1 and isinstance(service[1], eServiceReference):
1769 self.selectedSubservice = service
1770 if self.bouquets is None:
1773 cnt = len(self.bouquets)
1774 if cnt > 1: # show bouquet list
1775 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, self.bouquets, self.addSubserviceToBouquet)
1776 elif cnt == 1: # add to only one existing bouquet
1777 self.addSubserviceToBouquet(self.bouquets[0][1])
1778 self.session.open(MessageBox, _("Service has been added to the favourites."), MessageBox.TYPE_INFO)
1780 def bouquetSelClosed(self, confirmed):
1782 del self.selectedSubservice
1784 self.session.open(MessageBox, _("Service has been added to the selected bouquet."), MessageBox.TYPE_INFO)
1786 def addSubserviceToBouquet(self, dest):
1787 self.servicelist.addServiceToBouquet(dest, self.selectedSubservice[1])
1789 self.bsel.close(True)
1791 del self.selectedSubservice
1793 class InfoBarAdditionalInfo:
1796 self["RecordingPossible"] = Boolean(fixed=harddiskmanager.HDDCount() > 0 and config.misc.rcused.value == 1)
1797 self["TimeshiftPossible"] = self["RecordingPossible"]
1798 self["ShowTimeshiftOnYellow"] = Boolean(fixed=(not config.misc.rcused.value == 0))
1799 self["ShowAudioOnYellow"] = Boolean(fixed=config.misc.rcused.value == 0)
1800 self["ShowRecordOnRed"] = Boolean(fixed=config.misc.rcused.value == 1)
1801 self["ExtensionsAvailable"] = Boolean(fixed=1)
1803 class InfoBarNotifications:
1805 self.onExecBegin.append(self.checkNotifications)
1806 Notifications.notificationAdded.append(self.checkNotificationsIfExecing)
1807 self.onClose.append(self.__removeNotification)
1809 def __removeNotification(self):
1810 Notifications.notificationAdded.remove(self.checkNotificationsIfExecing)
1812 def checkNotificationsIfExecing(self):
1814 self.checkNotifications()
1816 def checkNotifications(self):
1817 if len(Notifications.notifications):
1818 n = Notifications.notifications[0]
1820 Notifications.notifications = Notifications.notifications[1:]
1823 if n[3].has_key("onSessionOpenCallback"):
1824 n[3]["onSessionOpenCallback"]()
1825 del n[3]["onSessionOpenCallback"]
1828 dlg = self.session.openWithCallback(cb, n[1], *n[2], **n[3])
1830 dlg = self.session.open(n[1], *n[2], **n[3])
1832 # remember that this notification is currently active
1834 Notifications.current_notifications.append(d)
1835 dlg.onClose.append(boundFunction(self.__notificationClosed, d))
1837 def __notificationClosed(self, d):
1838 Notifications.current_notifications.remove(d)
1840 class InfoBarServiceNotifications:
1842 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1844 iPlayableService.evEnd: self.serviceHasEnded
1847 def serviceHasEnded(self):
1848 print "service end!"
1851 self.setSeekState(self.SEEK_STATE_PLAY)
1855 class InfoBarCueSheetSupport:
1861 ENABLE_RESUME_SUPPORT = False
1863 def __init__(self, actionmap = "InfobarCueSheetActions"):
1864 self["CueSheetActions"] = HelpableActionMap(self, actionmap,
1866 "jumpPreviousMark": (self.jumpPreviousMark, _("jump to previous marked position")),
1867 "jumpNextMark": (self.jumpNextMark, _("jump to next marked position")),
1868 "toggleMark": (self.toggleMark, _("toggle a cut mark at the current position"))
1872 self.is_closing = False
1873 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1875 iPlayableService.evStart: self.__serviceStarted,
1878 def __serviceStarted(self):
1881 print "new service started! trying to download cuts!"
1882 self.downloadCuesheet()
1884 if self.ENABLE_RESUME_SUPPORT:
1887 for (pts, what) in self.cut_list:
1888 if what == self.CUT_TYPE_LAST:
1891 if last is not None:
1892 self.resume_point = last
1893 if config.usage.on_movie_start.value == "ask":
1894 Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Do you want to resume this playback?"), timeout=10)
1895 elif config.usage.on_movie_start.value == "resume":
1896 # TRANSLATORS: The string "Resuming playback" flashes for a moment
1897 # TRANSLATORS: at the start of a movie, when the user has selected
1898 # TRANSLATORS: "Resume from last position" as start behavior.
1899 # TRANSLATORS: The purpose is to notify the user that the movie starts
1900 # TRANSLATORS: in the middle somewhere and not from the beginning.
1901 # TRANSLATORS: (Some translators seem to have interpreted it as a
1902 # TRANSLATORS: question or a choice, but it is a statement.)
1903 Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Resuming playback"), timeout=2, type=MessageBox.TYPE_INFO)
1905 def playLastCB(self, answer):
1907 self.doSeek(self.resume_point)
1908 self.hideAfterResume()
1910 def hideAfterResume(self):
1911 if isinstance(self, InfoBarShowHide):
1914 def __getSeekable(self):
1915 service = self.session.nav.getCurrentService()
1918 return service.seek()
1920 def cueGetCurrentPosition(self):
1921 seek = self.__getSeekable()
1924 r = seek.getPlayPosition()
1929 def cueGetEndCutPosition(self):
1932 for cp in self.cut_list:
1933 if cp[1] == self.CUT_TYPE_OUT:
1937 elif cp[1] == self.CUT_TYPE_IN:
1941 def jumpPreviousNextMark(self, cmp, start=False):
1942 current_pos = self.cueGetCurrentPosition()
1943 if current_pos is None:
1945 mark = self.getNearestCutPoint(current_pos, cmp=cmp, start=start)
1946 if mark is not None:
1954 def jumpPreviousMark(self):
1955 # we add 2 seconds, so if the play position is <2s after
1956 # the mark, the mark before will be used
1957 self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True)
1959 def jumpNextMark(self):
1960 if not self.jumpPreviousNextMark(lambda x: x):
1963 def getNearestCutPoint(self, pts, cmp=abs, start=False):
1969 bestdiff = cmp(0 - pts)
1971 nearest = [0, False]
1972 for cp in self.cut_list:
1973 if beforecut and cp[1] in [self.CUT_TYPE_IN, self.CUT_TYPE_OUT]:
1975 if cp[1] == self.CUT_TYPE_IN: # Start is here, disregard previous marks
1976 diff = cmp(cp[0] - pts)
1982 if cp[1] in [self.CUT_TYPE_MARK, self.CUT_TYPE_LAST]:
1983 diff = cmp(cp[0] - pts)
1984 if diff >= 0 and (nearest is None or bestdiff > diff):
1989 def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000, onlyreturn=False):
1990 current_pos = self.cueGetCurrentPosition()
1991 if current_pos is None:
1992 print "not seekable"
1995 nearest_cutpoint = self.getNearestCutPoint(current_pos)
1997 if nearest_cutpoint is not None and abs(nearest_cutpoint[0] - current_pos) < tolerance:
1999 return nearest_cutpoint
2001 self.removeMark(nearest_cutpoint)
2002 elif not onlyremove and not onlyreturn:
2003 self.addMark((current_pos, self.CUT_TYPE_MARK))
2008 def addMark(self, point):
2009 insort(self.cut_list, point)
2010 self.uploadCuesheet()
2011 self.showAfterCuesheetOperation()
2013 def removeMark(self, point):
2014 self.cut_list.remove(point)
2015 self.uploadCuesheet()
2016 self.showAfterCuesheetOperation()
2018 def showAfterCuesheetOperation(self):
2019 if isinstance(self, InfoBarShowHide):
2022 def __getCuesheet(self):
2023 service = self.session.nav.getCurrentService()
2026 return service.cueSheet()
2028 def uploadCuesheet(self):
2029 cue = self.__getCuesheet()
2032 print "upload failed, no cuesheet interface"
2034 cue.setCutList(self.cut_list)
2036 def downloadCuesheet(self):
2037 cue = self.__getCuesheet()
2040 print "download failed, no cuesheet interface"
2043 self.cut_list = cue.getCutList()
2045 class InfoBarSummary(Screen):
2047 <screen position="0,0" size="132,64">
2048 <widget source="global.CurrentTime" render="Label" position="62,46" size="82,18" font="Regular;16" >
2049 <convert type="ClockToText">WithSeconds</convert>
2051 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="82,18" zPosition="1" >
2052 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
2053 <convert type="ConditionalShowHide">Blink</convert>
2055 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
2056 <convert type="ServiceName">Name</convert>
2058 <widget source="session.Event_Now" render="Progress" position="6,46" size="46,18" borderWidth="1" >
2059 <convert type="EventTime">Progress</convert>
2063 # for picon: (path="piconlcd" will use LCD picons)
2064 # <widget source="session.CurrentService" render="Picon" position="6,0" size="120,64" path="piconlcd" >
2065 # <convert type="ServiceName">Reference</convert>
2068 def __init__(self, session, parent):
2069 Screen.__init__(self, session, parent = parent)
2071 class InfoBarSummarySupport:
2075 def createSummary(self):
2076 return InfoBarSummary
2078 class InfoBarMoviePlayerSummary(Screen):
2080 <screen position="0,0" size="132,64">
2081 <widget source="global.CurrentTime" render="Label" position="62,46" size="64,18" font="Regular;16" halign="right" >
2082 <convert type="ClockToText">WithSeconds</convert>
2084 <widget source="session.RecordState" render="FixedLabel" text=" " position="62,46" size="64,18" zPosition="1" >
2085 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
2086 <convert type="ConditionalShowHide">Blink</convert>
2088 <widget source="session.CurrentService" render="Label" position="6,4" size="120,42" font="Regular;18" >
2089 <convert type="ServiceName">Name</convert>
2091 <widget source="session.CurrentService" render="Progress" position="6,46" size="56,18" borderWidth="1" >
2092 <convert type="ServicePosition">Position</convert>
2096 def __init__(self, session, parent):
2097 Screen.__init__(self, session)
2099 class InfoBarMoviePlayerSummarySupport:
2103 def createSummary(self):
2104 return InfoBarMoviePlayerSummary
2106 class InfoBarTeletextPlugin:
2108 self.teletext_plugin = None
2110 for p in plugins.getPlugins(PluginDescriptor.WHERE_TELETEXT):
2111 self.teletext_plugin = p
2113 if self.teletext_plugin is not None:
2114 self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions",
2116 "startTeletext": (self.startTeletext, _("View teletext..."))
2119 print "no teletext plugin found!"
2121 def startTeletext(self):
2122 self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService())
2124 class InfoBarSubtitleSupport(object):
2126 object.__init__(self)
2127 self.subtitle_window = self.session.instantiateDialog(SubtitleDisplay)
2128 self.__subtitles_enabled = False
2130 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2132 iPlayableService.evEnd: self.__serviceStopped,
2133 iPlayableService.evUpdatedInfo: self.__updatedInfo
2135 self.cached_subtitle_checked = False
2136 self.__selected_subtitle = None
2138 def __serviceStopped(self):
2139 self.subtitle_window.hide()
2140 self.__subtitles_enabled = False
2141 self.cached_subtitle_checked = False
2143 def __updatedInfo(self):
2144 if not self.cached_subtitle_checked:
2145 subtitle = self.getCurrentServiceSubtitle()
2146 self.cached_subtitle_checked = True
2147 self.__selected_subtitle = subtitle and subtitle.getCachedSubtitle()
2148 if self.__selected_subtitle:
2149 subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
2150 self.subtitle_window.show()
2151 self.__subtitles_enabled = True
2153 def getCurrentServiceSubtitle(self):
2154 service = self.session.nav.getCurrentService()
2155 return service and service.subtitle()
2157 def setSubtitlesEnable(self, enable=True):
2158 subtitle = self.getCurrentServiceSubtitle()
2159 if enable and self.__selected_subtitle is not None:
2160 if subtitle and not self.__subtitles_enabled:
2161 subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
2162 self.subtitle_window.show()
2163 self.__subtitles_enabled = True
2166 subtitle.disableSubtitles(self.subtitle_window.instance)
2167 self.__subtitles_enabled = False
2168 self.subtitle_window.hide()
2170 def setSelectedSubtitle(self, subtitle):
2171 self.__selected_subtitle = subtitle
2173 subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable)
2174 selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle)
2176 class InfoBarServiceErrorPopupSupport:
2178 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
2180 iPlayableService.evTuneFailed: self.__tuneFailed,
2181 iPlayableService.evStart: self.__serviceStarted
2183 self.__serviceStarted()
2185 def __serviceStarted(self):
2186 self.last_error = None
2187 Notifications.RemovePopup(id = "ZapError")
2189 def __tuneFailed(self):
2190 service = self.session.nav.getCurrentService()
2191 info = service and service.info()
2192 error = info and info.getInfo(iServiceInformation.sDVBState)
2194 if error == self.last_error:
2197 self.last_error = error
2200 eDVBServicePMTHandler.eventNoResources: _("No free tuner!"),
2201 eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"),
2202 eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"),
2203 eDVBServicePMTHandler.eventNoPATEntry: _("Service not found!\n(SID not found in PAT)"),
2204 eDVBServicePMTHandler.eventNoPMT: _("Service invalid!\n(Timeout reading PMT)"),
2205 eDVBServicePMTHandler.eventNewProgramInfo: None,
2206 eDVBServicePMTHandler.eventTuned: None,
2207 eDVBServicePMTHandler.eventSOF: None,
2208 eDVBServicePMTHandler.eventEOF: None,
2209 eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"),
2212 error = errors.get(error) #this returns None when the key not exist in the dict
2214 if error is not None:
2215 Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError")
2217 Notifications.RemovePopup(id = "ZapError")