Skip to content

Commit 0ef9736

Browse files
committed
[PictureInPicture]
* Change in PiP handling due to fixing stream relay service pipzap Cherry pick -> OpenViX/enigma2@441f4d7
1 parent c82bbaf commit 0ef9736

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

lib/python/Screens/PictureInPicture.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from enigma import ePoint, eSize, eRect, eServiceCenter, getBestPlayableServiceReference, eServiceReference, eTimer
44
from Components.SystemInfo import BoxInfo
55
from Components.VideoWindow import VideoWindow
6+
from Components.Sources.StreamService import StreamServiceList
67
from Components.config import config, ConfigPosition, ConfigSelection
78
from Tools import Notifications
89
from Screens.MessageBox import MessageBox
@@ -61,6 +62,9 @@ def __init__(self, session):
6162
self.currentService = None
6263
self.currentServiceReference = None
6364
self.noSkinReload = True
65+
self.isCurrentStreamRelay = False
66+
self.pipservice = None
67+
session.nav.pnav.clearPiPService()
6468

6569
self.choicelist = [("standard", _("Standard"))]
6670
if BoxInfo.getItem("VideoDestinationConfigurable"):
@@ -79,7 +83,8 @@ def __init__(self, session):
7983
self.onLayoutFinish.append(self.LayoutFinished)
8084

8185
def __del__(self):
82-
del self.pipservice
86+
if self.pipservice:
87+
del self.pipservice
8388
self.setExternalPiP(False)
8489
self.setSizePosMainWindow()
8590
if hasattr(self, "dishpipActive") and self.dishpipActive is not None:
@@ -180,31 +185,48 @@ def getModeName(self):
180185

181186
def playService(self, service):
182187
if service is None:
183-
return False
188+
self.session.nav.pnav.clearPiPService()
189+
return 0
184190
from Screens.InfoBarGenerics import streamrelay
185-
ref, isStreamRelay = streamrelay.streamrelayChecker(self.resolveAlternatePipService(service))
191+
ref = streamrelay.streamrelayChecker(self.resolveAlternatePipService(service))[0]
186192
if ref:
187-
if self.isPlayableForPipService(ref):
188-
print("playing pip service", ref and ref.toString())
189-
else:
193+
if BoxInfo.getItem("CanNotDoSimultaneousTranscodeAndPIP") and StreamServiceList:
194+
self.pipservice = None
195+
self.currentService = None
196+
self.currentServiceReference = None
190197
if not config.usage.hide_zap_errors.value:
198+
Notifications.AddPopup(text="PiP...\n" + _("Connected transcoding, limit - no PiP!"), type=MessageBox.TYPE_ERROR, timeout=5, id="ZapPipError")
199+
return 0
200+
if ref.toString().startswith("4097"): # Change to service type 1 and try to play a stream as type 1
201+
ref = eServiceReference("1" + ref.toString()[4:])
202+
self.session.nav.pnav.setPiPService(ref)
203+
if not self.isPlayableForPipService(ref):
204+
is_sr = self.isCurrentStreamRelay
205+
if is_sr:
206+
if self.pipservice:
207+
self.pipservice.stop()
208+
self.isCurrentStreamRelay = False
209+
if not config.usage.hide_zap_errors.value and not is_sr:
191210
Notifications.AddPopup(text=_("No free tuner!"), type=MessageBox.TYPE_ERROR, timeout=5, id="ZapPipError")
192-
return False
211+
return 0 if not is_sr else 2
212+
print("[PictureInPicture] playing pip service", ref and ref.toString())
193213
self.pipservice = eServiceCenter.getInstance().play(ref)
194214
if self.pipservice and not self.pipservice.setTarget(1, True):
195215
if hasattr(self, "dishpipActive") and self.dishpipActive is not None:
196216
self.dishpipActive.startPiPService(ref)
197217
self.pipservice.start()
198218
self.currentService = service
199219
self.currentServiceReference = ref
200-
return True
220+
if ref and ref.getIsStreamRelay():
221+
self.isCurrentStreamRelay = True
222+
return 1
201223
else:
202224
self.pipservice = None
203225
self.currentService = None
204226
self.currentServiceReference = None
205227
if not config.usage.hide_zap_errors.value:
206228
Notifications.AddPopup(text=_("Incorrect type service for PiP!"), type=MessageBox.TYPE_ERROR, timeout=5, id="ZapPipError")
207-
return False
229+
return 0
208230

209231
def getCurrentService(self):
210232
return self.currentService
@@ -217,7 +239,7 @@ def isPlayableForPipService(self, service):
217239
if playingref is None or service == playingref:
218240
return True
219241
info = eServiceCenter.getInstance().info(service)
220-
oldref = self.currentServiceReference or eServiceReference()
242+
oldref = self.currentService or eServiceReference()
221243
if info and info.isPlayable(service, oldref):
222244
return True
223245
return False

0 commit comments

Comments
 (0)