fix pip
[enigma2.git] / lib / python / Screens / PictureInPicture.py
1 from Screens.Screen import Screen
2 from enigma import ePoint, eSize, eServiceCenter
3 from Components.VideoWindow import VideoWindow
4 from Components.config import config, ConfigPosition
5
6 class PictureInPicture(Screen):
7         def __init__(self, session):
8                 Screen.__init__(self, session)
9                 self["video"] = VideoWindow()
10                 self.currentService = None
11                 config.av.pip = ConfigPosition(default=[-1, -1, -1, -1], args = (719, 567, 720, 568))
12                 self.onLayoutFinish.append(self.LayoutFinished)
13
14         def LayoutFinished(self):
15                 self.onLayoutFinish.remove(self.LayoutFinished)
16                 x = config.av.pip.value[0]
17                 y = config.av.pip.value[1]
18                 w = config.av.pip.value[2]
19                 h = config.av.pip.value[3]
20                 if x != -1 and y != -1 and w != -1 and h != -1:
21                         self.move(x, y)
22                         self.resize(w, h)
23
24         def move(self, x, y):
25                 config.av.pip.value[0] = x
26                 config.av.pip.value[1] = y
27                 config.av.pip.save()
28                 self.instance.move(ePoint(x, y))
29                 
30         def resize(self, w, h):
31                 config.av.pip.value[2] = w
32                 config.av.pip.value[3] = h
33                 config.av.pip.save()
34                 self.instance.resize(eSize(*(w, h)))
35                 self["video"].instance.resize(eSize(*(w, h)))
36                 
37         def getPosition(self):
38                 return ((self.instance.position().x(), self.instance.position().y()))
39                 
40         def getSize(self):
41                 return (self.instance.size().width(), self.instance.size().height())
42                 
43         def playService(self, service):
44                 self.pipservice = eServiceCenter.getInstance().play(service)
45                 if self.pipservice and not self.pipservice.setTarget(1):
46                         self.pipservice.start()
47                         self.currentService = service
48                         return True
49                 else:
50                         self.pipservice = None
51                         return False
52                 
53         def getCurrentService(self):
54                 return self.currentService
55