more changes for service groups (replacement for zapping alternatives
[enigma2.git] / lib / python / Screens / PictureInPicture.py
index fdb0418..bd340d8 100644 (file)
@@ -1,14 +1,19 @@
 from Screens.Screen import Screen
-from enigma import ePoint, eSize, eServiceCenter
+from enigma import ePoint, eSize, eServiceCenter, getBestPlayableServiceReference, eServiceReference
 from Components.VideoWindow import VideoWindow
-from Components.config import config, configElement, configSequence, configsequencearg
+from Components.config import config, ConfigPosition
+
+pip_config_initialized = False
 
 class PictureInPicture(Screen):
        def __init__(self, session):
+               global pip_config_initialized
                Screen.__init__(self, session)
                self["video"] = VideoWindow()
                self.currentService = None
-               config.av.pip = configElement("config.av.pip", configSequence, [-1, -1, -1, -1], configsequencearg.get("POSITION", (719, 567, 720, 568)))
+               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)
 
        def LayoutFinished(self):
@@ -41,14 +46,19 @@ class PictureInPicture(Screen):
                return (self.instance.size().width(), self.instance.size().height())
                
        def playService(self, service):
-               self.pipservice = eServiceCenter.getInstance().play(service)
-               if self.pipservice and not self.pipservice.setTarget(1):
-                       self.pipservice.start()
-                       self.currentService = service
-                       return True
+               if service and (service.flags & eServiceReference.isGroup):
+                       ref = getBestPlayableServiceReference(service, eServiceReference())
                else:
-                       self.pipservice = None
-                       return False
+                       ref = service
+               if ref:
+                       self.pipservice = eServiceCenter.getInstance().play(ref)
+                       if self.pipservice and not self.pipservice.setTarget(1):
+                               self.pipservice.start()
+                               self.currentService = service
+                               return True
+                       else:
+                               self.pipservice = None
+               return False
                
        def getCurrentService(self):
                return self.currentService