- def extensionCallback(self, answer):
- if answer is not None:
- if answer[1] == self.PIPON:
- self.pip = self.session.instantiateDialog(PictureInPicture)
-
- newservice = self.session.nav.getCurrentlyPlayingServiceReference()
-
- if self.pip.playService(newservice):
- self.pipshown = True
- else:
- self.pipshown = False
- del self.pip
- self.session.nav.playService(newservice)
- elif answer[1] == self.PIPOFF:
- del self.pip
- self.pipshown = False
- elif answer[1] == self.PIPSWAP:
- swapservice = self.pip.getCurrentService()
- self.pip.playService(self.session.nav.getCurrentlyPlayingServiceReference())
- self.session.nav.playService(swapservice)
-
- elif answer[1] == self.MOVEPIP:
- self.session.open(PiPSetup, pip = self.pip)
- elif answer[1] == self.ENABLE_SUBTITLE:
- self.selected_subtitle = answer[2]
- self.subtitles_enabled = True
+ def getSleepTimerName(self):
+ return _("Sleep Timer")
+
+ def showSleepTimerSetup(self):
+ self.session.open(SleepTimerEdit)
+
+# depends on InfoBarExtensions
+class InfoBarPiP:
+ def __init__(self):
+ self.session.pipshown = False
+
+ self.addExtension((self.getShowHideName, self.showPiP, self.available), "blue")
+ self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
+ self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
+
+ def available(self):
+ return True
+
+ def pipShown(self):
+ return self.session.pipshown
+
+ def getShowHideName(self):
+ if self.session.pipshown:
+ return _("Disable Picture in Picture")
+ else:
+ return _("Activate Picture in Picture")
+
+ def getSwapName(self):
+ return _("Swap Services")
+
+ def getMoveName(self):
+ return _("Move Picture in Picture")
+
+ def showPiP(self):
+ if self.session.pipshown:
+ del self.session.pip
+ self.session.pipshown = False
+ else:
+ self.session.pip = self.session.instantiateDialog(PictureInPicture)
+ newservice = self.session.nav.getCurrentlyPlayingServiceReference()
+ if self.session.pip.playService(newservice):
+ self.session.pipshown = True
+ self.session.pip.servicePath = self.servicelist.getCurrentServicePath()
+ else:
+ self.session.pipshown = False
+ del self.session.pip
+ self.session.nav.playService(newservice)
+
+ def swapPiP(self):
+ swapservice = self.session.nav.getCurrentlyPlayingServiceReference()
+ if self.session.pip.servicePath:
+ servicepath = self.servicelist.getCurrentServicePath()
+ ref=servicepath[len(servicepath)-1]
+ pipref=self.session.pip.getCurrentService()
+ self.session.pip.playService(swapservice)
+ self.servicelist.setCurrentServicePath(self.session.pip.servicePath)
+ if pipref.toString() != ref.toString(): # is a subservice ?
+ self.session.nav.stopService() # stop portal
+ self.session.nav.playService(pipref) # start subservice
+ self.session.pip.servicePath=servicepath
+
+ def movePiP(self):
+ self.session.open(PiPSetup, pip = self.session.pip)