1 from Screens.Screen import Screen
2 from enigma import ePoint, eSize, eServiceCenter, getBestPlayableServiceReference, eServiceReference
3 from Components.VideoWindow import VideoWindow
4 from Components.config import config, ConfigPosition
6 pip_config_initialized = False
8 class PictureInPicture(Screen):
9 def __init__(self, session):
10 global pip_config_initialized
11 Screen.__init__(self, session)
12 self["video"] = VideoWindow()
13 self.currentService = None
14 if not pip_config_initialized:
15 config.av.pip = ConfigPosition(default=[-1, -1, -1, -1], args = (719, 567, 720, 568))
16 pip_config_initialized = True
17 self.onLayoutFinish.append(self.LayoutFinished)
19 def LayoutFinished(self):
20 self.onLayoutFinish.remove(self.LayoutFinished)
21 x = config.av.pip.value[0]
22 y = config.av.pip.value[1]
23 w = config.av.pip.value[2]
24 h = config.av.pip.value[3]
25 if x != -1 and y != -1 and w != -1 and h != -1:
30 config.av.pip.value[0] = x
31 config.av.pip.value[1] = y
33 self.instance.move(ePoint(x, y))
35 def resize(self, w, h):
36 config.av.pip.value[2] = w
37 config.av.pip.value[3] = h
39 self.instance.resize(eSize(*(w, h)))
40 self["video"].instance.resize(eSize(*(w, h)))
42 def getPosition(self):
43 return ((self.instance.position().x(), self.instance.position().y()))
46 return (self.instance.size().width(), self.instance.size().height())
48 def playService(self, service):
49 if service and (service.flags & eServiceReference.isGroup):
50 ref = getBestPlayableServiceReference(service, eServiceReference())
54 self.pipservice = eServiceCenter.getInstance().play(ref)
55 if self.pipservice and not self.pipservice.setTarget(1):
56 self.pipservice.start()
57 self.currentService = service
60 self.pipservice = None
63 def getCurrentService(self):
64 return self.currentService