Пример #1
0
    def __init__(self, session):
        global pip_config_initialized
        Screen.__init__(self, session)
        self["video"] = VideoWindow()
        self.pipActive = session.instantiateDialog(PictureInPictureZapping)
        self.currentService = None
        self.currentServiceReference = None

        self.choicelist = [("standard", _("Standard"))]
        if SystemInfo["VideoDestinationConfigurable"]:
            self.choicelist.append(("cascade", _("Cascade PiP")))
            self.choicelist.append(("split", _("Splitscreen")))
            self.choicelist.append(("byside", _("Side by side")))
        self.choicelist.append(("bigpig", _("Big PiP")))
        if SystemInfo["HasExternalPIP"]:
            self.choicelist.append(("external", _("External PiP")))

        if not pip_config_initialized:
            config.av.pip = ConfigPosition(default=[510, 28, 180, 135],
                                           args=(MAX_X, MAX_Y, MAX_X, MAX_Y))
            config.av.pip_mode = ConfigSelection(default="standard",
                                                 choices=self.choicelist)
            pip_config_initialized = True

        self.onLayoutFinish.append(self.LayoutFinished)
Пример #2
0
 def __init__(self, session):
     global pip_config_initialized
     Screen.__init__(self, session)
     self['video'] = VideoWindow()
     self.pipActive = session.instantiateDialog(PictureInPictureZapping)
     self.dishpipActive = session.instantiateDialog(Dishpip)
     self.currentService = None
     self.currentServiceReference = None
     self.choicelist = [('standard', _('Standard'))]
     if SystemInfo['VideoDestinationConfigurable']:
         self.choicelist.append(('cascade', _('Cascade PiP')))
         self.choicelist.append(('split', _('Splitscreen')))
         self.choicelist.append(('byside', _('Side by side')))
     self.choicelist.append(('bigpig', _('Big PiP')))
     if SystemInfo['HasExternalPIP']:
         self.choicelist.append(('external', _('External PiP')))
     if not pip_config_initialized:
         config.av.pip = ConfigPosition(default=[510,
          28,
          180,
          135], args=(MAX_X,
          MAX_Y,
          MAX_X,
          MAX_Y))
         config.av.pip_mode = ConfigSelection(default='standard', choices=self.choicelist)
         pip_config_initialized = True
     self.onLayoutFinish.append(self.LayoutFinished)
     return
Пример #3
0
	def __init__(self, session):
		global pip_config_initialized
		Screen.__init__(self, session)
		self["video"] = VideoWindow()
		self.currentService = None
		if not pip_config_initialized:
			config.av.pip = ConfigPosition(default=[-1, -1, -1, -1], args = (719, 567, 720, 568))
			pip_config_initialized = True
		self.onLayoutFinish.append(self.LayoutFinished)
Пример #4
0
	def __init__(self, session):
		global pip_config_initialized
		Screen.__init__(self, session)
		self["video"] = VideoWindow()
		self.pipActive = session.instantiateDialog(PictureInPictureZapping)
		self.currentService = None
		self.has_external_pip = access("/proc/stb/vmpeg/1/external", W_OK)
		if not pip_config_initialized:
			config.av.pip = ConfigPosition(default=[-1, -1, -1, -1], args = (719, 567, 720, 568))
			config.av.external_pip = ConfigYesNo(default = False)
			pip_config_initialized = True
		self.onLayoutFinish.append(self.LayoutFinished)
Пример #5
0
def InitVcsProfile(profile=None, name=""):
    if profile is None:
        profile = ConfigSubsection()
    profile.name = ConfigText("", fixed_size=False)
    if not profile.name.value and name:
        profile.name.value = name
        profile.name.save()
    profile.enabled = ConfigYesNo(default=True)
    profile.stretch = ConfigSelection([("0", _("no")), ("1", _("yes"))],
                                      default="0")
    profile.aspect = ConfigInteger(2)
    profile.cliprect = ConfigPosition([0, 0, 720, 576], (719, 575, 720, 576))
    return profile
Пример #6
0
class VirtualZap(Screen):
    sz_w = getDesktop(0).size().width()

    #
    # VirtualZap or VirtualZapNoPiP
    #

    if SystemInfo.get(
            "NumVideoDecoders", 1
    ) > 1 and config.plugins.virtualzap.usepip.value and config.plugins.virtualzap.showpipininfobar.value:
        # use PiP in Infobar
        if sz_w == 1280:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,505" size="1280,220" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/hd.png" position="0,0" size="1280,220" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="60,50" size="214,120" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;26" halign="left" name="NowChannel" position="305,60" size="887,32" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="left" name="NowEPG" position="305,105" size="600,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="left" name="NextEPG" position="305,140" size="600,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="right" name="NowTime" position="1070,105" size="124,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="right" name="NextTime" position="1070,140" size="124,28" transparent="1" zPosition="2"/>
				</screen>"""
        elif sz_w == 1024:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,420" size="1024,176" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,0" size="1024,176" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="50,20" size="164,92" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="left" name="NowChannel" position="230,25" size="741,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="230,55" size="600,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="230,80" size="600,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="850,55" size="124,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="850,80" size="124,25" transparent="1" zPosition="2"/>
				</screen>"""
        else:
            skin = """
				<screen backgroundColor="#101214" flags="wfNoBorder" name="VirtualZap" position="0,420" size="720,176" title="Virtual Zap">
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,0" size="720,176" zPosition="0"/>
					<widget backgroundColor="transparent" name="video" position="50,25" size="130,73" zPosition="1"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="left" name="NowChannel" position="190,25" size="480,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="190,55" size="360,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="190,80" size="360,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="550,55" size="120,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="550,80" size="120,25" transparent="1" zPosition="2"/>
				</screen>"""
    else:
        if SystemInfo.get(
                "NumVideoDecoders", 1
        ) > 1 and config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value:
            # use standard PiP
            config.av.pip = ConfigPosition(default=[0, 0, 0, 0],
                                           args=(719, 567, 720, 568))
            x = config.av.pip.value[0]
            y = config.av.pip.value[1]
            w = config.av.pip.value[2]
            h = config.av.pip.value[3]

        else:
            # no PiP
            x = 0
            y = 0
            w = 0
            h = 0

        if sz_w == 1280:
            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="1280,720" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/hd.png" position="0,505" size="1280,220" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;26" halign="center" name="NowChannel" position="140,565" size="1000,32" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="left" name="NowEPG" position="140,610" size="860,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="left" name="NextEPG" position="140,645" size="860,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" foregroundColor="#fcc000" halign="right" name="NowTime" position="1015,610" size="124,28" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;24" halign="right" name="NextTime" position="1015,645" size="124,28" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)
        elif sz_w == 1024:
            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="1024,576" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,420" size="1024,176" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="center" name="NowChannel" position="100,445" size="824,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="100,475" size="700,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="100,500" size="700,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="800,475" size="124,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="800,500" size="124,25" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)
        else:

            skin = """
				<screen backgroundColor="transparent" flags="wfNoBorder" name="VirtualZapNoPiP" position="0,0" size="720,576" title="Virtual Zap">
					<widget backgroundColor="transparent" name="video" position="%d,%d" size="%d,%d" zPosition="1"/>
					<ePixmap alphatest="off" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/VirtualZap/sd.png" position="0,420" size="720,176" zPosition="0"/>
					<widget backgroundColor="#101214" font="Regular;22" halign="center" name="NowChannel" position="50,445" size="620,30" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="left" name="NowEPG" position="50,475" size="500,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="left" name="NextEPG" position="50,500" size="500,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" foregroundColor="#fcc000" halign="right" name="NowTime" position="550,475" size="120,25" transparent="1" zPosition="2"/>
					<widget backgroundColor="#101214" font="Regular;20" halign="right" name="NextTime" position="550,500" size="120,25" transparent="1" zPosition="2"/>
				</screen>""" % (x, y, w, h)

    def __init__(self, session, servicelist=None):
        Screen.__init__(self, session)
        self.session = session
        if SystemInfo.get(
                "NumVideoDecoders", 1
        ) > 1 and config.plugins.virtualzap.usepip.value and config.plugins.virtualzap.showpipininfobar.value:
            self.skinName = "VirtualZap"
            self.pipAvailable = True
        else:
            self.skinName = "VirtualZapNoPiP"
            self.pipAvailable = (
                SystemInfo.get("NumVideoDecoders", 1) > 1
            ) and config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value
        self.epgcache = eEPGCache.getInstance()
        self.CheckForEPG = eTimer()
        self.CheckForEPG.callback.append(self.CheckItNow)
        self["NowChannel"] = Label()
        self["NowEPG"] = Label()
        self["NextEPG"] = Label()
        self["NowTime"] = Label()
        self["NextTime"] = Label()
        self["actions"] = ActionMap(
            [
                "OkCancelActions", "DirectionActions",
                "ChannelSelectBaseActions", "ChannelSelectEPGActions",
                "ColorActions"
            ], {
                "ok": self.ok,
                "cancel": self.closing,
                "right": self.nextService,
                "left": self.prevService,
                "nextBouquet": self.showFavourites,
                "prevBouquet": self.openServiceList,
                "showEPGList": self.openEventView,
                "blue": self.standardPiP,
                "yellow": self.switchAndStandardPiP,
                "down": self.switchChannelDown,
                "up": self.switchChannelUp,
            }, -2)
        self["actions2"] = NumberActionMap(
            ["NumberActions"], {
                "0": self.swap,
                "1": self.keyNumberGlobal,
                "2": self.keyNumberGlobal,
                "3": self.keyNumberGlobal,
                "4": self.keyNumberGlobal,
                "5": self.keyNumberGlobal,
                "6": self.keyNumberGlobal,
                "7": self.keyNumberGlobal,
                "8": self.keyNumberGlobal,
                "9": self.keyNumberGlobal,
            }, -1)
        self.onLayoutFinish.append(self.onLayoutReady)
        # PiP
        if self.pipAvailable:
            # activate PiP support
            if config.plugins.virtualzap.usepip.value and not config.plugins.virtualzap.showpipininfobar.value:
                # activate standard PiP
                self["video"] = VideoWindow()
            else:
                # show PiP in Infobar
                self["video"] = VideoWindow(
                    fb_width=getDesktop(0).size().width(),
                    fb_height=getDesktop(0).size().height())
            self.currentPiP = ""
        else:
            # no PiP
            self["video"] = Label()
        # this is the servicelist from ChannelSelectionBase
        self.servicelist = servicelist
        # save orig. method of zap in servicelist
        self.servicelist_orig_zap = self.servicelist.zap
        # when displaying ChannelSelection, do not zap when pressing "ok", so new method is needed
        self.servicelist.zap = self.servicelist_overwrite_zap
        # overwrite the actionmap of ChannelSelection
        self.servicelist["actions"] = ActionMap(
            ["OkCancelActions"], {
                "cancel": self.cancelChannelSelection,
                "ok": self.servicelist.channelSelected,
            })
        # temp. vars, needed when pressing cancel in ChannelSelection
        self.curSelectedRef = None
        self.curSelectedBouquet = None
        # needed, because if we won't zap, we have to go back to the current bouquet and service
        self.curRef = ServiceReference(self.servicelist.getCurrentSelection())
        self.curBouquet = self.servicelist.getRoot()
        # start with last used service
        if config.plugins.virtualzap.saveLastService.value:
            # get service and bouquet ref
            ref = eServiceReference(config.plugins.virtualzap.curref.value)
            bouquet = eServiceReference(
                config.plugins.virtualzap.curbouquet.value)
            if ref.valid() and bouquet.valid():
                # select bouquet and ref in servicelist
                self.setServicelistSelection(bouquet, ref)
        # prepare exitTimer
        self.exitTimer = eTimer()
        self.exitTimer.timeout.get().append(self.standardPiP)
        # reverse changes of ChannelSelection when closing plugin
        self.onClose.append(self.__onClose)
        # if PiPServiceRelation is installed, get relation dict
        if plugin_PiPServiceRelation_installed:
            self.pipServiceRelation = getRelationDict()
        else:
            self.pipServiceRelation = {}

    def onLayoutReady(self):
        self.updateInfos()

    def resetExitTimer(self):
        # if enabled, run exit timer
        if config.plugins.virtualzap.exittimer.value != 0:
            if self.exitTimer.isActive():
                self.exitTimer.stop()
            self.exitTimer.start(config.plugins.virtualzap.exittimer.value *
                                 1000)

    def nextService(self):
        # get next service
        if self.servicelist.inBouquet():
            prev = self.servicelist.getCurrentSelection()
            if prev:
                prev = prev.toString()
                while True:
                    if config.usage.quickzap_bouquet_change.value and self.servicelist.atEnd(
                    ):
                        self.servicelist.nextBouquet()
                    else:
                        self.servicelist.moveDown()
                    cur = self.servicelist.getCurrentSelection()
                    if not cur or (
                            not (cur.flags & 64)) or cur.toString() == prev:
                        break
        else:
            self.servicelist.moveDown()
        if self.isPlayable():
            self.updateInfos()
        else:
            self.nextService()

    def prevService(self):
        # get previous service
        if self.servicelist.inBouquet():
            prev = self.servicelist.getCurrentSelection()
            if prev:
                prev = prev.toString()
                while True:
                    if config.usage.quickzap_bouquet_change.value:
                        if self.servicelist.atBegin():
                            self.servicelist.prevBouquet()
                    self.servicelist.moveUp()
                    cur = self.servicelist.getCurrentSelection()
                    if not cur or (
                            not (cur.flags & 64)) or cur.toString() == prev:
                        break
        else:
            self.servicelist.moveUp()
        if self.isPlayable():
            self.updateInfos()
        else:
            self.prevService()

    def isPlayable(self):
        # check if service is playable
        current = ServiceReference(self.servicelist.getCurrentSelection())
        return not (
            current.ref.flags &
            (eServiceReference.isMarker | eServiceReference.isDirectory))

    def nextBouquet(self):
        # next bouquet with first service
        if config.usage.multibouquet.value:
            self.servicelist.nextBouquet()
        self.updateInfos()

    def prevBouquet(self):
        # previous bouquet with first service
        if config.usage.multibouquet.value:
            self.servicelist.prevBouquet()
        self.updateInfos()

    def updateInfos(self):
        self.resetExitTimer()
        # update data
        current = ServiceReference(self.servicelist.getCurrentSelection())
        self["NowChannel"].setText(current.getServiceName())
        nowepg, nowtimedisplay = self.getEPGNowNext(current.ref, 0)
        nextepg, nexttimedisplay = self.getEPGNowNext(current.ref, 1)
        self["NowEPG"].setText(nowepg)
        self["NextEPG"].setText(nextepg)
        self["NowTime"].setText(nowtimedisplay)
        self["NextTime"].setText(nexttimedisplay)
        if not nowepg:
            # no epg found --> let's try it again, but only if PiP is activated
            if self.pipAvailable:
                self.CheckForEPG.start(3000, True)
        if self.pipAvailable:
            # play in videowindow
            self.playService(current.ref)

    def getEPGNowNext(self, ref, modus):
        # get now || next event
        if self.epgcache is not None:
            event = self.epgcache.lookupEvent(
                ['IBDCTSERNX', (ref.toString(), modus, -1)])
            if event:
                if event[0][4]:
                    t = localtime(event[0][1])
                    duration = event[0][2]
                    if modus == 0:
                        timedisplay = "+%d min" % ((
                            (event[0][1] + duration) - time()) / 60)
                    elif modus == 1:
                        timedisplay = "%d min" % (duration / 60)
                    return "%02d:%02d %s" % (t[3], t[4],
                                             event[0][4]), timedisplay
                else:
                    return "", ""
        return "", ""

    def openSingleServiceEPG(self):
        # show EPGList
        current = ServiceReference(self.servicelist.getCurrentSelection())
        self.session.open(EPGSelection, current.ref)

    def openEventView(self):
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()
        # show EPG Event
        epglist = []
        self.epglist = epglist
        service = ServiceReference(self.servicelist.getCurrentSelection())
        ref = service.ref
        evt = self.epgcache.lookupEventTime(ref, -1)
        if evt:
            epglist.append(evt)
        evt = self.epgcache.lookupEventTime(ref, -1, 1)
        if evt:
            epglist.append(evt)
        if epglist:
            self.session.openWithCallback(self.EventViewEPGSelectCallBack,
                                          EventViewEPGSelect, epglist[0],
                                          service, self.eventViewCallback,
                                          self.openSingleServiceEPG,
                                          self.openMultiServiceEPG,
                                          self.openSimilarList)

    def EventViewEPGSelectCallBack(self):
        # if enabled, start ExitTimer
        self.resetExitTimer()

    def eventViewCallback(self, setEvent, setService, val):
        epglist = self.epglist
        if len(epglist) > 1:
            tmp = epglist[0]
            epglist[0] = epglist[1]
            epglist[1] = tmp
            setEvent(epglist[0])

    def openMultiServiceEPG(self):
        # not supported
        pass

    def openSimilarList(self, eventid, refstr):
        self.session.open(EPGSelection, refstr, None, eventid)

    def setServicelistSelection(self, bouquet, service):
        # we need to select the old service with bouquet
        if self.servicelist.getRoot() != bouquet:  #already in correct bouquet?
            self.servicelist.clearPath()
            self.servicelist.enterPath(self.servicelist.bouquet_root)
            self.servicelist.enterPath(bouquet)
        self.servicelist.setCurrentSelection(
            service)  #select the service in servicelist

    def closing(self):
        if self.pipAvailable:
            self.pipservice = None
        # save last used service and bouqet ref
        self.saveLastService(self.servicelist.getCurrentSelection().toString(),
                             self.servicelist.getRoot().toString())
        # select running service in servicelist again
        self.setServicelistSelection(self.curBouquet, self.curRef.ref)
        self.close()

    def ok(self):
        # we have to close PiP first, otherwise the service-display is freezed
        if self.pipAvailable:
            self.pipservice = None
        # play selected service and close virtualzap
        self.servicelist_orig_zap()
        # save last used service and bouqet ref
        self.saveLastService(self.curRef.ref.toString(),
                             self.curBouquet.toString())
        self.close()

    def standardPiP(self):
        if not self.pipAvailable:
            return
        # close PiP
        self.pipservice = None
        # save current selected service for standard PiP
        service = ServiceReference(self.servicelist.getCurrentSelection()).ref
        servicePath = self.servicelist.getCurrentServicePath(
        )  # same bug as in channelselection
        # save last used service and bouqet ref
        self.saveLastService(self.servicelist.getCurrentSelection().toString(),
                             self.servicelist.getRoot().toString())
        # select running service in servicelist
        self.setServicelistSelection(self.curBouquet, self.curRef.ref)
        # close VZ and start standard PiP
        self.close(service, servicePath)

    def switchAndStandardPiP(self):
        if not self.pipAvailable:
            return
        self.pipservice = None
        # save current selected servicePath for standard PiP
        servicePath = self.servicelist.getCurrentServicePath()
        # save last used service and bouqet ref
        self.saveLastService(self.curRef.ref.toString(),
                             self.curBouquet.toString())
        # play selected service
        self.servicelist_orig_zap()
        # close VZ and start standard PiP
        self.close(self.curRef.ref, servicePath)

    def saveLastService(self, ref, bouquet):
        if config.plugins.virtualzap.saveLastService.value:
            # save last VZ service
            config.plugins.virtualzap.curref.value = ref
            config.plugins.virtualzap.curbouquet.value = bouquet
            config.plugins.virtualzap.save()
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()

    def CheckItNow(self):
        self.CheckForEPG.stop()
        self.updateInfos()

    # if available play service in PiP
    def playService(self, service):
        if parentalControl.getProtectionLevel(service.toCompareString(
        )) == -1 or (
                parentalControl.configInitialized
                and parentalControl.sessionPinCached
                and parentalControl.sessionPinCachedValue
        ):  # check parentalControl, only play a protected service when Pin-Cache is activated and still valid
            current_service = service
            n_service = self.pipServiceRelation.get(service.toString(),
                                                    None)  # PiPServiceRelation
            if n_service is not None:
                service = eServiceReference(n_service)
            if service and (service.flags & eServiceReference.isGroup):
                ref = getBestPlayableServiceReference(service,
                                                      eServiceReference())
            else:
                ref = service
            if ref and ref.toString() != self.currentPiP:
                self.pipservice = eServiceCenter.getInstance().play(ref)
                if self.pipservice and not self.pipservice.setTarget(1):
                    self.pipservice.start()
                    self.currentPiP = current_service.toString()
                else:
                    self.pipservice = None
                    self.currentPiP = ""
        else:
            self.pipservice = None
            self.currentPiP = ""

    # switch with numbers

    def keyNumberGlobal(self, number):
        self.session.openWithCallback(self.numberEntered, NumberZap, number)

    def numberEntered(self, retval):
        if retval > 0:
            self.zapToNumber(retval)

    def searchNumberHelper(self, serviceHandler, num, bouquet):
        servicelist = serviceHandler.list(bouquet)
        if not servicelist is None:
            while num:
                serviceIterator = servicelist.getNext()
                if not serviceIterator.valid():  #check end of list
                    break
                playable = not (serviceIterator.flags &
                                (eServiceReference.isMarker
                                 | eServiceReference.isDirectory))
                if playable:
                    num -= 1
            if not num:  #found service with searched number ?
                return serviceIterator, 0
        return None, num

    def zapToNumber(self, number):
        bouquet = self.servicelist.bouquet_root
        service = None
        serviceHandler = eServiceCenter.getInstance()
        bouquetlist = serviceHandler.list(bouquet)
        if not bouquetlist is None:
            while number:
                bouquet = bouquetlist.getNext()
                if not bouquet.valid():  #check end of list
                    break
                if bouquet.flags & eServiceReference.isDirectory:
                    service, number = self.searchNumberHelper(
                        serviceHandler, number, bouquet)
        if not service is None:
            self.setServicelistSelection(bouquet, service)
        # update infos, no matter if service is none or not
        self.updateInfos()

    def swap(self, number):
        # save old values for selecting it in servicelist after zapping
        currentRef = self.curRef
        currentBouquet = self.curBouquet
        # we have to close PiP first, otherwise the service-display is freezed
        if self.pipAvailable:
            self.pipservice = None
        # zap and set new values for the new reference and bouquet
        self.servicelist_orig_zap()
        self.curRef = ServiceReference(self.servicelist.getCurrentSelection())
        self.curBouquet = self.servicelist.getRoot()
        # select old values in servicelist
        self.setServicelistSelection(currentBouquet, currentRef.ref)
        # play old service in PiP
        self.updateInfos()

    # ChannelSelection Support
    def prepareChannelSelectionDisplay(self):
        # stop exitTimer
        if self.exitTimer.isActive():
            self.exitTimer.stop()
        # turn off PiP
        if self.pipAvailable:
            self.pipservice = None
        # save current ref and bouquet ( for cancel )
        self.curSelectedRef = eServiceReference(
            self.servicelist.getCurrentSelection().toString())
        self.curSelectedBouquet = self.servicelist.getRoot()

    def cancelChannelSelection(self):
        # select service and bouquet selected before started ChannelSelection
        if self.servicelist.revertMode is None:
            ref = self.curSelectedRef
            bouquet = self.curSelectedBouquet
            if ref.valid() and bouquet.valid():
                # select bouquet and ref in servicelist
                self.setServicelistSelection(bouquet, ref)
        # close ChannelSelection
        self.servicelist.revertMode = None
        self.servicelist.close(None)

        # clean up
        self.curSelectedRef = None
        self.curSelectedBouquet = None
        # display VZ data
        self.servicelist_overwrite_zap()

    def switchChannelDown(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.moveDown()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def switchChannelUp(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.moveUp()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def showFavourites(self):
        self.prepareChannelSelectionDisplay()
        self.servicelist.showFavourites()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def openServiceList(self):
        self.prepareChannelSelectionDisplay()
        # show ChannelSelection
        self.session.execDialog(self.servicelist)

    def servicelist_overwrite_zap(self, *args, **kwargs):
        # we do not really want to zap to the service, just display data for VZ
        self.currentPiP = ""
        if self.isPlayable():
            self.updateInfos()

    def __onClose(self):
        # reverse changes of ChannelSelection
        self.servicelist.zap = self.servicelist_orig_zap
        self.servicelist["actions"] = ActionMap(
            ["OkCancelActions", "TvRadioActions"], {
                "cancel": self.servicelist.cancel,
                "ok": self.servicelist.channelSelected,
                "keyRadio": self.servicelist.setModeRadio,
                "keyTV": self.servicelist.setModeTv,
            })