a navigation instance might not be available at AUTOSTART. use first session's naviga...
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 5 Mar 2006 22:41:37 +0000 (22:41 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 5 Mar 2006 22:41:37 +0000 (22:41 +0000)
lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py

index 118f0cb..7dc04d1 100644 (file)
@@ -232,7 +232,7 @@ class AlternativeZapping(Screen):
                pass
 
 
                pass
 
 
-oldPlayService = NavigationInstance.instance.playService
+oldPlayService = None
 
 from Components.PerServiceDisplay import PerServiceDisplay
 
 
 from Components.PerServiceDisplay import PerServiceDisplay
 
@@ -274,29 +274,32 @@ class ServiceChanged(PerServiceDisplay):
 
                                        #print "Alternatives: No playable alternative found!"
 
 
                                        #print "Alternatives: No playable alternative found!"
 
-servicechanged = ServiceChanged(NavigationInstance.instance)
+servicechanged = None
 
 def playService(self, ref):
        #print "--------------------Alternatives: trying to play service", str(ServiceReference(ref))
        servicechanged.lastPlayAction = str(ServiceReference(ref))
        servicechanged.nextPlayTry = 0
        result = oldPlayService(ref)
 
 def playService(self, ref):
        #print "--------------------Alternatives: trying to play service", str(ServiceReference(ref))
        servicechanged.lastPlayAction = str(ServiceReference(ref))
        servicechanged.nextPlayTry = 0
        result = oldPlayService(ref)
-
        
        return result
 
        
        return result
 
-def autostart(reason):
+def sessionstart(reason, session, **kwargs):
        if reason == 0:
                try:
                        loadAlternatives()
        if reason == 0:
                try:
                        loadAlternatives()
-               except:
+               except: # FIXME, THIS IS ILLEGAL CODE AND WILL BE PROSECUTED!
                        pass
                        pass
-               NavigationInstance.instance.playService = type(NavigationInstance.instance.playService)(playService, NavigationInstance, Navigation)
                
                
+               # attach to this sessions navigation instance.
+               global oldPlayService, servicechanged
+               oldPlayService = session.nav.playService
+               session.nav.playService = type(session.nav.playService)(playService, NavigationInstance, Navigation)
+               servicechanged = ServiceChanged(session.nav)
 
 def AlternativeZappingSetup(session, **kwargs):
        session.open(AlternativeZapping)
 
 def Plugins(**kwargs):
 
 def AlternativeZappingSetup(session, **kwargs):
        session.open(AlternativeZapping)
 
 def Plugins(**kwargs):
-       return [PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
+       return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart),
                        PluginDescriptor(name="Alternative services setup" , description="Defines alternatives for services.", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=AlternativeZappingSetup)]
                        PluginDescriptor(name="Alternative services setup" , description="Defines alternatives for services.", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=AlternativeZappingSetup)]