- if answer[1] == self.PIPON:
-# self.session.nav.stopService()
- self.pip = self.session.instantiateDialog(PictureInPicture)
- #self.pip.show()
-
- newservice = self.session.nav.getCurrentlyPlayingServiceReference()
- self.pipservice = eServiceCenter.getInstance().play(newservice)
- if self.pipservice and not self.pipservice.setTarget(1):
- self.pipservice.start()
- self.pipshown = True
- else:
- self.pipservice = None
- del self.pip
- self.session.nav.playService(newservice)
- elif answer[1] == self.PIPOFF:
- #self.pip.hide()
- self.pipservice = None
- del self.pip
- self.pipshown = False
- elif answer[1] == self.MOVEPIP:
- self.session.open(PiPSetup, pip = self.pip)
+ answer[1][1]()
+
+from Tools.BoundFunction import boundFunction
+
+# depends on InfoBarExtensions
+from Components.PluginComponent import plugins
+
+class InfoBarPlugins:
+ def __init__(self):
+ self.addExtension(extension = self.getPluginList, type = InfoBarExtensions.EXTENSION_LIST)
+
+
+ def getPluginName(self, name):
+ return name
+
+ def getPluginList(self):
+ list = []
+ for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
+ list.append(((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None))
+ return list
+
+ def runPlugin(self, plugin):
+ plugin(session = self.session)
+
+# 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)