X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FExtensions%2FZappingAlternatives%2Fplugin.py;h=2a7f588d985da85da463d4911eec446cfad06f6e;hb=421b6db36824390a7edd4843c79381baad92b774;hp=f4bc3fad6e5f9902ed3b85affa7599070349610a;hpb=4d839a58f1cb6ca69df2c3cfad7ce832ec9a6d1d;p=vuplus_dvbapp diff --git a/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py b/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py index f4bc3fa..2a7f588 100644 --- a/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py +++ b/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py @@ -38,7 +38,7 @@ def removeAlternative(service1, service2): del alternatives[service2] def loadAlternatives(): - doc = xml.dom.minidom.parse(self.filename) + doc = xml.dom.minidom.parse(resolveFilename(SCOPE_CONFIG, "alternatives.xml")) root = doc.childNodes[0] for service in elementsWithTag(root.childNodes, 'service'): @@ -221,9 +221,9 @@ class AlternativeZapping(Screen): if not self.alternatives.has_key(serviceString): self.alternatives[serviceString] = [] self.updateServices() - self.updateAlternatives() self.selectService(serviceString) - + self.updateAlternatives() + def yellowKey(self): if len(self.serviceslist) > 0: self.session.openWithCallback(self.finishedAlternativeSelection, SimpleChannelSelection, _("Select alternative service")) @@ -234,14 +234,56 @@ class AlternativeZapping(Screen): oldPlayService = NavigationInstance.instance.playService +from Components.PerServiceDisplay import PerServiceDisplay + +class ServiceChanged(PerServiceDisplay): + def __init__(self, navcore): + PerServiceDisplay.__init__(self, navcore, + { + iPlayableService.evTuneFailed: self.tuneFailed, + iPlayableService.evStart: self.start + }) + + self.lastPlayAction = None + self.nextPlayTry = 0 + + def start(self): +# print "+++++++++++++++++++++++++++++++++++++++++++++++++Start", self.lastPlayAction + if self.lastPlayAction is not None: + self.lastPlayAction = None + + def tuneFailed(self): +# print "+++++++++++++++++++++++++++++++++++++++++++++++++Tuning failed!", self.lastPlayAction + ref = self.lastPlayAction +# print "Ref:", ref +# print "Alternatives: failed to play service" + if ref is not None: + if alternatives.has_key(ref): +# print "Alternatives: trying alternatives" + if len(alternatives[ref]) > self.nextPlayTry: +# print "Alternatives: trying alternative", alternatives[ref][self.nextPlayTry] + if oldPlayService(ServiceReference(alternatives[ref][self.nextPlayTry]).ref) == 0: + self.nextPlayTry += 1 +# print "Alternatives: Alternative found!" + else: + self.nextPlayTry += 1 +# print "Alternatives: Alternative doesn't play either" + self.tuneFailed() + else: + self.lastPlayAction = None + + #print "Alternatives: No playable alternative found!" + +servicechanged = ServiceChanged(NavigationInstance.instance) + def playService(self, ref): - if not oldPlayService(ref): - if alternatives.has_key(str(ServiceReference(ref))): - for x in alternatives[str(ServiceReference(ref))]: - if oldPlayService(ServiceReference(x).ref): - return 1 - return 0 - return 1 + #print "--------------------Alternatives: trying to play service", str(ServiceReference(ref)) + servicechanged.lastPlayAction = str(ServiceReference(ref)) + servicechanged.nextPlayTry = 0 + result = oldPlayService(ref) + + + return result def autostart(reason): if reason == 0: @@ -250,6 +292,7 @@ def autostart(reason): except: pass NavigationInstance.instance.playService = type(NavigationInstance.instance.playService)(playService, NavigationInstance, Navigation) + def AlternativeZappingSetup(session): session.open(AlternativeZapping)