set parent
[enigma2.git] / lib / python / Screens / PictureInPicture.py
index 5c49683335535660fc034d7a39576f2174245ada..e49eb36e65b788039b1f76b9fd276b7ef3233ddd 100644 (file)
@@ -1,5 +1,5 @@
 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, ConfigPosition
 
@@ -31,30 +31,35 @@ class PictureInPicture(Screen):
                config.av.pip.value[1] = y
                config.av.pip.save()
                self.instance.move(ePoint(x, y))
-               
+
        def resize(self, w, h):
                config.av.pip.value[2] = w
                config.av.pip.value[3] = h
                config.av.pip.save()
                self.instance.resize(eSize(*(w, h)))
                self["video"].instance.resize(eSize(*(w, h)))
-               
+
        def getPosition(self):
                return ((self.instance.position().x(), self.instance.position().y()))
-               
+
        def getSize(self):
                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
-       
+