add ability to selecte the audio channel (mono left, stereo, mono right) from python
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index a11e9262118a859ed98ae4cb13ebe186efe5e647..67212656c57660e0a88f48703ddc23a08691e1d0 100644 (file)
@@ -13,7 +13,7 @@ from Components.PluginComponent import plugins
 from Components.ProgressBar import *
 from Components.ServiceEventTracker import ServiceEventTracker
 from Components.ServiceName import ServiceName
-from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean
+from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean, configSelection, configElement_nonSave, getConfigListEntry
 from Components.config import configfile, configsequencearg
 from Components.TimerList import TimerEntryComponent
 from Components.TunerInfo import TunerInfo
@@ -448,7 +448,8 @@ class InfoBarEPG:
                if self.is_now_next and len(self.dlg_stack) == 1:
                        self.getNowNext()
                        assert self.eventView
-                       self.eventView.setEvent(self.epglist[0])
+                       if len(self.epglist):
+                               self.eventView.setEvent(self.epglist[0])
 
        def openEventView(self):
                ref = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -1191,9 +1192,11 @@ class InfoBarAudioSelection:
        def audioSelection(self):
                service = self.session.nav.getCurrentService()
                audio = service.audioTracks()
-               self.audio = audio
+               self.audioTracks = audio
                n = audio.getNumberOfTracks()
                if n > 0:
+#                      self.audioChannel = service.audioChannel()
+#                      config.audio.audiochannel = configElement_nonSave("config.audio.audiochannel", configSelection, self.audioChannel.getCurrentChannel(), (("left", _("Left  >")), ("stereo", _("<  Stereo  >")), ("right", _("<  Right"))))
                        tlist = []
                        for x in range(n):
                                i = audio.getTrackInfo(x)
@@ -1213,6 +1216,9 @@ class InfoBarAudioSelection:
                        
                        selectedAudio = tlist[0][1]
                        tlist.sort(lambda x,y : cmp(x[0], y[0]))
+
+#                      tlist.insert(0, getConfigListEntry(_("Audio Channel"), config.audio.audiochannel))
+
                        selection = 0
                        for x in tlist:
                                if x[1] != selectedAudio:
@@ -1221,11 +1227,15 @@ class InfoBarAudioSelection:
                                        break
                        
                        self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection)
+               else:
+                       del self.audioTracks
 
        def audioSelected(self, audio):
                if audio is not None:
-                       self.audio.selectTrack(audio[1])
-               del self.audio
+                       self.audioTracks.selectTrack(audio[1])
+               del self.audioTracks
+#              del self.audioChannel
+#              del config.audio.audiochannel
 
 class InfoBarSubserviceSelection:
        def __init__(self):
@@ -1241,14 +1251,13 @@ class InfoBarSubserviceSelection:
                        }, -1)
                self["SubserviceQuickzapAction"].setEnabled(False)
 
-               self.session.nav.event.append(self.checkParentAvail) # we like to get service events
+               self.session.nav.event.append(self.checkSubservicesAvail) # we like to get service events
 
-       def checkParentAvail(self, ev):
-               ref=self.session.nav.getCurrentlyPlayingServiceReference()
+       def checkSubservicesAvail(self, ev):
                if ev == iPlayableService.evUpdatedEventInfo:
-                       if ref.getData(5):
-                               self["SubserviceQuickzapAction"].setEnabled(True)
-                       else:
+                       service = self.session.nav.getCurrentService()
+                       subservices = service.subServices()
+                       if subservices.getNumberOfSubservices() == 0:
                                self["SubserviceQuickzapAction"].setEnabled(False)
 
        def nextSubservice(self):
@@ -1298,6 +1307,7 @@ class InfoBarSubserviceSelection:
 
        def subserviceSelected(self, service):
                if not service is None:
+                       self["SubserviceQuickzapAction"].setEnabled(True)
                        self.session.nav.playService(service[1])
 
 class InfoBarAdditionalInfo: