Example #1
0
	def playService(self, ref, checkParentalControl=True, forceRestart=False, adjust=True):
		oldref = self.currentlyPlayingServiceOrGroup
		if ref and oldref and ref == oldref and not forceRestart:
			print("[Navigation] ignore request to play already running service(1)")
			return 1
		print("[Navigation] playing", ref and ref.toString())
		if path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '1':
			try:
				if '0:0:0:0:0:0:0:0:0' not in ref.toString():
					signal = 1
				else:
					signal = 0
				open("/proc/stb/lcd/symbol_signal", "w").write(str(signal))
			except:
				open("/proc/stb/lcd/symbol_signal", "w").write("0")
		elif path.exists("/proc/stb/lcd/symbol_signal") and config.lcd.mode.value == '0':
			open("/proc/stb/lcd/symbol_signal", "w").write("0")
		if ref is None:
			self.stopService()
			return 0
		from Components.ServiceEventTracker import InfoBarCount
		InfoBarInstance = InfoBarCount == 1 and InfoBar.instance
		if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl=False, forceRestart=forceRestart, adjust=adjust)):
			if ref.flags & eServiceReference.isGroup:
				oldref = self.currentlyPlayingServiceReference or eServiceReference()
				playref = getBestPlayableServiceReference(ref, oldref)
				if playref and config.misc.use_ci_assignment.value and not isPlayableForCur(playref):
					alternative_ci_ref = ResolveCiAlternative(ref, playref)
					if alternative_ci_ref:
						playref = alternative_ci_ref
				print("[Navigation] alternative ref: ", playref and playref.toString())
				if playref and oldref and playref == oldref and not forceRestart:
					print("[Navigation] ignore request to play already running service(2)")
					return 1
				if not playref:
					alternativeref = getBestPlayableServiceReference(ref, eServiceReference(), True)
					self.stopService()
					if alternativeref and self.pnav:
						self.currentlyPlayingServiceReference = alternativeref
						self.currentlyPlayingServiceOrGroup = ref
						if self.pnav.playService(alternativeref):
							print("[Navigation] Failed to start: ", alternativeref.toString())
							self.currentlyPlayingServiceReference = None
							self.currentlyPlayingServiceOrGroup = None
					return 0
				elif checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False)):
					if self.currentlyPlayingServiceOrGroup and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(self.currentlyPlayingServiceOrGroup, adjust):
						self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
					return 1
			else:
				playref = ref
			if self.pnav:
				self.pnav.stopService()
				self.currentlyPlayingServiceReference = playref
				self.currentlyPlayingServiceOrGroup = ref
				if InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(ref, adjust):
					self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
				setPriorityFrontend = False
				if SystemInfo["DVB-T_priority_tuner_available"] or SystemInfo["DVB-C_priority_tuner_available"] or SystemInfo["DVB-S_priority_tuner_available"] or SystemInfo["ATSC_priority_tuner_available"]:
					str_service = playref.toString()
					if '%3a//' not in str_service and not str_service.rsplit(":", 1)[1].startswith("/"):
						type_service = playref.getUnsignedData(4) >> 16
						if type_service == 0xEEEE:
							if SystemInfo["DVB-T_priority_tuner_available"] and config.usage.frontend_priority_dvbt.value != "-2":
								if config.usage.frontend_priority_dvbt.value != config.usage.frontend_priority.value:
									setPreferredTuner(int(config.usage.frontend_priority_dvbt.value))
									setPriorityFrontend = True
							if SystemInfo["ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2":
								if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value:
									setPreferredTuner(int(config.usage.frontend_priority_atsc.value))
									setPriorityFrontend = True
						elif type_service == 0xFFFF:
							if SystemInfo["DVB-C_priority_tuner_available"] and config.usage.frontend_priority_dvbc.value != "-2":
								if config.usage.frontend_priority_dvbc.value != config.usage.frontend_priority.value:
									setPreferredTuner(int(config.usage.frontend_priority_dvbc.value))
									setPriorityFrontend = True
							if SystemInfo["ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2":
								if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value:
									setPreferredTuner(int(config.usage.frontend_priority_atsc.value))
									setPriorityFrontend = True
						else:
							if SystemInfo["DVB-S_priority_tuner_available"] and config.usage.frontend_priority_dvbs.value != "-2":
								if config.usage.frontend_priority_dvbs.value != config.usage.frontend_priority.value:
									setPreferredTuner(int(config.usage.frontend_priority_dvbs.value))
									setPriorityFrontend = True
				if self.pnav.playService(playref):
					print("[Navigation] Failed to start: ", playref.toString())
					self.currentlyPlayingServiceReference = None
					self.currentlyPlayingServiceOrGroup = None
				if setPriorityFrontend:
					setPreferredTuner(int(config.usage.frontend_priority.value))
				return 0
		elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(oldref, adjust):
			self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent()
		return 1
Example #2
0
 def playService(self,
                 ref,
                 checkParentalControl=True,
                 forceRestart=False,
                 adjust=True):
     session = None
     startPlayingServiceOrGroup = None
     count = isinstance(adjust, list) and len(adjust) or 0
     if count > 1 and adjust[0] is 0:
         session = adjust[1]
         if count == 3:
             startPlayingServiceOrGroup = adjust[2]
         adjust = adjust[0]
     oldref = self.currentlyPlayingServiceOrGroup
     if ref and oldref and ref == oldref and not forceRestart:
         print "[Navigation] ignore request to play already running service(1)"
         return 1
     print "[Navigation] playing: ", ref and ref.toString()
     if ref is None:
         self.stopService()
         return 0
     from Components.ServiceEventTracker import InfoBarCount
     InfoBarInstance = InfoBarCount == 1 and InfoBar.instance
     if not checkParentalControl or parentalControl.isServicePlayable(
             ref,
             boundFunction(self.playService,
                           checkParentalControl=False,
                           forceRestart=forceRestart,
                           adjust=(count > 1 and [0, session] or adjust)),
             session=session):
         if ref.flags & eServiceReference.isGroup:
             oldref = self.currentlyPlayingServiceReference or eServiceReference(
             )
             playref = getBestPlayableServiceReference(ref, oldref)
             if playref and config.misc.use_ci_assignment.value and not isPlayableForCur(
                     playref):
                 alternative_ci_ref = ResolveCiAlternative(ref, playref)
                 if alternative_ci_ref:
                     playref = alternative_ci_ref
             print "[Navigation] alternative ref: ", playref and playref.toString(
             )
             if playref and oldref and playref == oldref and not forceRestart:
                 print "[Navigation] ignore request to play already running service(2)"
                 return 1
             if not playref:
                 alternativeref = getBestPlayableServiceReference(
                     ref, eServiceReference(), True)
                 self.stopService()
                 if alternativeref and self.pnav:
                     self.currentlyPlayingServiceReference = alternativeref
                     self.currentlyPlayingServiceOrGroup = ref
                     if self.pnav.playService(alternativeref):
                         print "[Navigation] Failed to start: ", alternativeref.toString(
                         )
                         self.currentlyPlayingServiceReference = None
                         self.currentlyPlayingServiceOrGroup = None
                     else:
                         print "[Navigation] alternative ref as simulate: ", alternativeref.toString(
                         )
                 return 0
             elif checkParentalControl and not parentalControl.isServicePlayable(
                     playref,
                     boundFunction(self.playService,
                                   checkParentalControl=False,
                                   forceRestart=forceRestart,
                                   adjust=(count > 1 and [0, session, ref]
                                           or adjust)),
                     session=session):
                 if self.currentlyPlayingServiceOrGroup and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(
                         self.currentlyPlayingServiceOrGroup, adjust):
                     self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent(
                     )
                 return 1
         else:
             playref = ref
         if self.pnav:
             if SystemInfo["FCCactive"] and not self.pnav.playService(
                     playref):
                 self.currentlyPlayingServiceReference = playref
                 self.currentlyPlayingServiceOrGroup = ref
                 return 0
             self.pnav.stopService()
             self.currentlyPlayingServiceReference = playref
             self.currentlyPlayingServiceOrGroup = ref
             if startPlayingServiceOrGroup and startPlayingServiceOrGroup.flags & eServiceReference.isGroup and not ref.flags & eServiceReference.isGroup:
                 self.currentlyPlayingServiceOrGroup = startPlayingServiceOrGroup
             if InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(
                     ref, adjust):
                 self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent(
                 )
             setPriorityFrontend = False
             if SystemInfo["DVB-T_priority_tuner_available"] or SystemInfo[
                     "DVB-C_priority_tuner_available"] or SystemInfo[
                         "DVB-S_priority_tuner_available"] or SystemInfo[
                             "ATSC_priority_tuner_available"]:
                 str_service = playref.toString()
                 if '%3a//' not in str_service and not str_service.rsplit(
                         ":", 1)[1].startswith("/"):
                     type_service = playref.getUnsignedData(4) >> 16
                     if type_service == 0xEEEE:
                         if SystemInfo[
                                 "DVB-T_priority_tuner_available"] and config.usage.frontend_priority_dvbt.value != "-2":
                             if config.usage.frontend_priority_dvbt.value != config.usage.frontend_priority.value:
                                 setPreferredTuner(
                                     int(config.usage.
                                         frontend_priority_dvbt.value))
                                 setPriorityFrontend = True
                         if SystemInfo[
                                 "ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2":
                             if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value:
                                 setPreferredTuner(
                                     int(config.usage.
                                         frontend_priority_atsc.value))
                                 setPriorityFrontend = True
                     elif type_service == 0xFFFF:
                         if SystemInfo[
                                 "DVB-C_priority_tuner_available"] and config.usage.frontend_priority_dvbc.value != "-2":
                             if config.usage.frontend_priority_dvbc.value != config.usage.frontend_priority.value:
                                 setPreferredTuner(
                                     int(config.usage.
                                         frontend_priority_dvbc.value))
                                 setPriorityFrontend = True
                         if SystemInfo[
                                 "ATSC_priority_tuner_available"] and config.usage.frontend_priority_atsc.value != "-2":
                             if config.usage.frontend_priority_atsc.value != config.usage.frontend_priority.value:
                                 setPreferredTuner(
                                     int(config.usage.
                                         frontend_priority_atsc.value))
                                 setPriorityFrontend = True
                     else:
                         if SystemInfo[
                                 "DVB-S_priority_tuner_available"] and config.usage.frontend_priority_dvbs.value != "-2":
                             if config.usage.frontend_priority_dvbs.value != config.usage.frontend_priority.value:
                                 setPreferredTuner(
                                     int(config.usage.
                                         frontend_priority_dvbs.value))
                                 setPriorityFrontend = True
             if self.pnav.playService(playref):
                 print "[Navigation] Failed to start: ", playref.toString()
                 self.currentlyPlayingServiceReference = None
                 self.currentlyPlayingServiceOrGroup = None
             if setPriorityFrontend:
                 setPreferredTuner(int(
                     config.usage.frontend_priority.value))
             return 0
     elif oldref and InfoBarInstance and InfoBarInstance.servicelist.servicelist.setCurrent(
             oldref, adjust):
         self.currentlyPlayingServiceOrGroup = InfoBarInstance.servicelist.servicelist.getCurrent(
         )
     return 1