24
24
25
25
26
26
class Navigation :
27
+ playServiceExtensions = []
28
+ recordServiceExtensions = []
27
29
def __init__ (self ):
28
30
if NavigationInstance .instance is not None :
29
31
raise NavigationInstance .instance
@@ -44,6 +46,7 @@ def __init__(self):
44
46
self .currentlyPlayingServiceReference = None
45
47
self .currentlyPlayingServiceOrGroup = None
46
48
self .currentlyPlayingService = None
49
+ self .originalPlayingServiceReference = None
47
50
self .isCurrentServiceStreamRelay = False
48
51
self .RecordTimer = RecordTimer .RecordTimer ()
49
52
self .__wasTimerWakeup = getFPWasTimerWakeup ()
@@ -117,7 +120,14 @@ def serviceHook(self, ref):
117
120
AddPopup (text = wrappererror , type = MessageBox .TYPE_ERROR , timeout = 5 , id = "channelzapwrapper" )
118
121
return nref , wrappererror
119
122
120
- def playService (self , ref , checkParentalControl = True , forceRestart = False , adjust = True , ignoreStreamRelay = False ):
123
+ def playService (self , ref , checkParentalControl = True , forceRestart = False , adjust = True , ignoreStreamRelay = False , event = None ):
124
+ # Some plugins send None as ref becasue want to shutdown enigma play system.
125
+ # So we have to stop current service if someone send None.
126
+ if ref is None :
127
+ self .stopService ()
128
+ return 0
129
+
130
+ InfoBarInstance = InfoBar .instance
121
131
session = None
122
132
startPlayingServiceOrGroup = None
123
133
count = isinstance (adjust , list ) and len (adjust ) or 0
@@ -127,15 +137,33 @@ def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust
127
137
startPlayingServiceOrGroup = adjust [2 ]
128
138
adjust = adjust [0 ]
129
139
oldref = self .currentlyPlayingServiceOrGroup
140
+ current_service_source = None
141
+ is_handled = False
142
+ if InfoBarInstance :
143
+ current_service_source = InfoBarInstance .session .screen ["CurrentService" ]
144
+
145
+ if "%3a//" in ref .toString ():
146
+ self .currentlyPlayingServiceReference = None
147
+ self .currentlyPlayingService = None
148
+ if current_service_source :
149
+ current_service_source .newService (False )
150
+
130
151
if ref and oldref and ref == oldref and not forceRestart :
131
152
print ("[Navigation] ignore request to play already running service(1)" )
132
153
return 1
133
- print ("[Navigation] playing: " , ref and ref .toString ())
134
- if ref is None :
135
- self .stopService ()
136
- return 0
137
- from Components .ServiceEventTracker import InfoBarCount
138
- InfoBarInstance = InfoBarCount == 1 and InfoBar .instance
154
+ print ("[Navigation] playing ref" , ref and ref .toString ())
155
+
156
+ self .currentlyPlayingServiceReference = ref
157
+ self .currentlyPlayingServiceOrGroup = ref
158
+ self .originalPlayingServiceReference = ref
159
+
160
+ if InfoBarInstance and current_service_source :
161
+ current_service_source .serviceref = ref
162
+ current_service_source .newService (ref )
163
+ InfoBarInstance .session .screen ["Event_Now" ].updateSource (self .currentlyPlayingServiceReference )
164
+ InfoBarInstance .session .screen ["Event_Next" ].updateSource (self .currentlyPlayingServiceReference )
165
+ InfoBarInstance .serviceStarted ()
166
+
139
167
isStreamRelay = False
140
168
if not checkParentalControl or parentalControl .isServicePlayable (ref , boundFunction (self .playService , checkParentalControl = False , forceRestart = forceRestart , adjust = (count > 1 and [0 , session ] or adjust )), session = session ):
141
169
if ref .flags & eServiceReference .isGroup :
@@ -165,6 +193,7 @@ def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust
165
193
print ("[Navigation] Failed to start: " , alternativeref .toString ())
166
194
self .currentlyPlayingServiceReference = None
167
195
self .currentlyPlayingServiceOrGroup = None
196
+ self .originalPlayingServiceReference = None
168
197
if oldref and ("://" in oldref .getPath () or streamrelay .checkService (oldref )):
169
198
print ("[Navigation] Streaming was active -> try again" ) # use timer to give the streamserver the time to deallocate the tuner
170
199
self .retryServicePlayTimer = eTimer ()
@@ -193,6 +222,13 @@ def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust
193
222
if wrappererror :
194
223
return 1
195
224
print ("[Navigation] playref" , playref .toString ())
225
+
226
+ if BoxInfo .getItem ("FCCactive" ) and "%3a//" in ref .toString () and not isStreamRelay :
227
+ self .pnav .stopService ()
228
+
229
+ for f in Navigation .playServiceExtensions :
230
+ playref , is_handled = f (self , playref , event , InfoBarInstance )
231
+
196
232
self .currentlyPlayingServiceOrGroup = ref
197
233
if startPlayingServiceOrGroup and startPlayingServiceOrGroup .flags & eServiceReference .isGroup and not ref .flags & eServiceReference .isGroup :
198
234
self .currentlyPlayingServiceOrGroup = startPlayingServiceOrGroup
@@ -239,9 +275,11 @@ def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust
239
275
self .firstStart = False
240
276
self .retryServicePlayTimer .start (delay , True )
241
277
return 0
242
- elif self .pnav .playService (playref ):
278
+ elif not is_handled and self .pnav .playService (playref ):
243
279
print ("[Navigation] Failed to start: " , playref .toString ())
280
+ current_service_source .serviceref = None
244
281
self .currentlyPlayingServiceReference = None
282
+ self .originalPlayingServiceReference = None
245
283
self .currentlyPlayingServiceOrGroup = None
246
284
if oldref and ("://" in oldref .getPath () or streamrelay .checkService (oldref )):
247
285
print ("[Navigation] Streaming was active -> try again" ) # use timer to give the streamserver the time to deallocate the tuner
@@ -252,6 +290,9 @@ def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust
252
290
self .isCurrentServiceStreamRelay = True
253
291
if setPriorityFrontend :
254
292
setPreferredTuner (int (config .usage .frontend_priority .value ))
293
+ if InfoBarInstance and "%3a//" in playref .toString () and not is_handled :
294
+ current_service_source .serviceref = None
295
+ InfoBarInstance .serviceStarted ()
255
296
return 0
256
297
elif oldref and InfoBarInstance and InfoBarInstance .servicelist .servicelist .setCurrent (oldref , adjust ):
257
298
self .currentlyPlayingServiceOrGroup = InfoBarInstance .servicelist .servicelist .getCurrent ()
@@ -261,7 +302,12 @@ def getCurrentlyPlayingServiceReference(self):
261
302
return self .currentlyPlayingServiceReference
262
303
263
304
def getCurrentlyPlayingServiceOrGroup (self ):
264
- return self .currentlyPlayingServiceOrGroup
305
+ if not self .currentlyPlayingServiceOrGroup :
306
+ return None
307
+ return self .originalPlayingServiceReference or self .currentlyPlayingServiceOrGroup
308
+
309
+ def getCurrentServiceReferenceOriginal (self ):
310
+ return self .originalPlayingServiceReference
265
311
266
312
def getCurrentServiceRef (self ):
267
313
curPlayService = self .getCurrentService ()
@@ -283,6 +329,8 @@ def recordService(self, ref, simulate=False):
283
329
if ref :
284
330
if ref .flags & eServiceReference .isGroup :
285
331
ref = getBestPlayableServiceReference (ref , eServiceReference (), simulate )
332
+ for f in Navigation .recordServiceExtensions :
333
+ ref = f (self , ref )
286
334
if type != (pNavigation .isPseudoRecording | pNavigation .isFromEPGrefresh ):
287
335
ref , isStreamRelay = streamrelay .streamrelayChecker (ref )
288
336
#if not isStreamRelay:
0 commit comments