X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FScreens%2FAudioSelection.py;h=4c6896201d5e04aeb6d4b456761c1b10db7788e2;hp=a11127cbfbbb496a1b2418145502b914174433bb;hb=c72fb90523ab709569016548763d872ae53327e3;hpb=96a165cdc48c3bdec6e0570186fa7843975db950 diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index a11127c..4c68962 100644 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -14,9 +14,10 @@ from enigma import iPlayableService from Tools.ISO639 import LanguageCodes from Tools.BoundFunction import boundFunction FOCUS_CONFIG, FOCUS_STREAMS = range(2) +[PAGE_AUDIO, PAGE_SUBTITLES] = ["audio", "subtitles"] class AudioSelection(Screen, ConfigListScreen): - def __init__(self, session, infobar=None): + def __init__(self, session, infobar=None, page=PAGE_AUDIO): Screen.__init__(self, session) self["streams"] = List([]) @@ -45,48 +46,46 @@ class AudioSelection(Screen, ConfigListScreen): "cancel": self.cancel, "up": self.keyUp, "down": self.keyDown, - }, -3) + }, -2) self.settings = ConfigSubsection() - choicelist = [("audio",_("audio tracks")), ("subtitles",_("Subtitles"))] - self.settings.menupage = ConfigSelection(choices = choicelist) - self.settings.menupage.addNotifier(self.fillList) + choicelist = [(PAGE_AUDIO,_("audio tracks")), (PAGE_SUBTITLES,_("Subtitles"))] + self.settings.menupage = ConfigSelection(choices = choicelist, default=page) self.onLayoutFinish.append(self.__layoutFinished) def __layoutFinished(self): self["config"].instance.setSelectionEnable(False) self.focus = FOCUS_STREAMS + self.settings.menupage.addNotifier(self.fillList) def fillList(self, arg=None): streams = [] conflist = [] selectedidx = 0 - - service = self.session.nav.getCurrentService() - self.audioTracks = audio = service and service.audioTracks() - n = audio and audio.getNumberOfTracks() or 0 - - if self.settings.menupage.getValue() == "audio": + + if self.settings.menupage.getValue() == PAGE_AUDIO: self.setTitle(_("Select audio track")) + service = self.session.nav.getCurrentService() + self.audioTracks = audio = service and service.audioTracks() + n = audio and audio.getNumberOfTracks() or 0 if SystemInfo["CanDownmixAC3"]: - print "config.av.downmix_ac3.value=", config.av.downmix_ac3.value self.settings.downmix = ConfigOnOff(default=config.av.downmix_ac3.value) self.settings.downmix.addNotifier(self.changeAC3Downmix, initial_call = False) conflist.append(getConfigListEntry(_("AC3 downmix"), self.settings.downmix)) - self["key_red"] = Boolean(True) + self["key_red"].setBoolean(True) if n > 0: self.audioChannel = service.audioChannel() - print "self.audioChannel.getCurrentChannel()", self.audioChannel.getCurrentChannel() - choicelist = [("0",_("left")), ("1",_("stereo")), ("2", _("right"))] - self.settings.channelmode = ConfigSelection(choices = choicelist, default = str(self.audioChannel.getCurrentChannel())) - self.settings.channelmode.addNotifier(self.changeMode, initial_call = False) - conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode)) - self["key_green"] = Boolean(True) - + if self.audioChannel: + choicelist = [("0",_("left")), ("1",_("stereo")), ("2", _("right"))] + self.settings.channelmode = ConfigSelection(choices = choicelist, default = str(self.audioChannel.getCurrentChannel())) + self.settings.channelmode.addNotifier(self.changeMode, initial_call = False) + conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode)) + self["key_green"].setBoolean(True) + else: + conflist.append(('',)) + self["key_green"].setBoolean(False) selectedAudio = self.audioTracks.getCurrentTrack() - print "selectedAudio:", selectedAudio - for x in range(n): number = str(x) i = audio.getTrackInfo(x) @@ -113,33 +112,17 @@ class AudioSelection(Screen, ConfigListScreen): streams.append((x, "", number, description, language, selected)) - #if hasattr(self, "runPlugin"): - #class PluginCaller: - #def __init__(self, fnc, *args): - #self.fnc = fnc - #self.args = args - #def __call__(self, *args, **kwargs): - #self.fnc(*self.args) - - #Plugins = [ (p.name, PluginCaller(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ] - - #for p in Plugins: - #selection += 1 - #flist.append((p[0], "CALLFUNC", p[1])) - #if availableKeys: - #usedKeys.append(availableKeys[0]) - #del availableKeys[0] - #else: - #usedKeys.append("") else: - streams = [(None, "", "", _("none"), "")] + streams = [] + conflist.append(('',)) + self["key_green"].setBoolean(False) - elif self.settings.menupage.getValue() == "subtitles": + elif self.settings.menupage.getValue() == PAGE_SUBTITLES: self.setTitle(_("Subtitle selection")) - - self.settings.dummy = ConfigNothing() - conflist.append(getConfigListEntry("", self.settings.dummy)) - conflist.append(getConfigListEntry("", self.settings.dummy)) + conflist.append(('',)) + conflist.append(('',)) + self["key_red"].setBoolean(False) + self["key_green"].setBoolean(False) if self.subtitlesEnabled(): sel = self.infobar.selected_subtitle @@ -149,7 +132,7 @@ class AudioSelection(Screen, ConfigListScreen): idx = 0 subtitlelist = self.getSubtitleList() - + if len(subtitlelist): for x in subtitlelist: number = str(x[1]) @@ -157,7 +140,7 @@ class AudioSelection(Screen, ConfigListScreen): language = _("") selected = "" - if sel and x[:4] == sel[:4]: + if sel and x == sel: selected = _("Running") selectedidx = idx @@ -174,18 +157,39 @@ class AudioSelection(Screen, ConfigListScreen): elif x[0] == 1: description = "TTX" number = "%x%02x" % (x[3],x[2]) - + elif x[0] == 2: - types = (" UTF-8 text "," SSA / AAS "," .SRT file ") + types = (_(""), "UTF-8 text", "SSA", "AAS", ".SRT file", "VOB", "PGS (unsupported)") description = types[x[2]] streams.append((x, "", number, description, language, selected)) idx += 1 else: - streams = [(None, "", "", _("none"), "")] + streams = [] conflist.append(getConfigListEntry(_("Menu"), self.settings.menupage)) + + from Components.PluginComponent import plugins + from Plugins.Plugin import PluginDescriptor + + if hasattr(self.infobar, "runPlugin"): + class PluginCaller: + def __init__(self, fnc, *args): + self.fnc = fnc + self.args = args + def __call__(self, *args, **kwargs): + self.fnc(*self.args) + + Plugins = [ (p.name, PluginCaller(self.infobar.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ] + + if len(Plugins): + self["key_blue"].setBoolean(True) + conflist.append(getConfigListEntry(Plugins[0][0], ConfigNothing())) + self.plugincallfunc = Plugins[0][1] + if len(Plugins) > 1: + print "plugin(s) installed but not displayed in the dialog box:", Plugins[1:] + self["config"].list = conflist self["config"].l.setList(conflist) @@ -204,7 +208,6 @@ class AudioSelection(Screen, ConfigListScreen): return self.infobar.subtitles_enabled def enableSubtitle(self, subtitles): - print "[enableSubtitle]", subtitles if self.infobar.selected_subtitle != subtitles: self.infobar.subtitles_enabled = False self.infobar.selected_subtitle = subtitles @@ -212,7 +215,6 @@ class AudioSelection(Screen, ConfigListScreen): self.infobar.subtitles_enabled = True def changeAC3Downmix(self, downmix): - print "changeAC3Downmix config.av.downmix_ac3.value=", config.av.downmix_ac3.value, downmix.getValue() if downmix.getValue() == True: config.av.downmix_ac3.value = True else: @@ -220,12 +222,10 @@ class AudioSelection(Screen, ConfigListScreen): config.av.downmix_ac3.save() def changeMode(self, mode): - print "changeMode", mode, mode.getValue() - if mode is not None: + if mode is not None and self.audioChannel: self.audioChannel.selectChannel(int(mode.getValue())) def changeAudio(self, audio): - print "changeAudio", audio, "self.session.nav.getCurrentService().audioTracks().getNumberOfTracks():", self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() track = int(audio) if isinstance(track, int): if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > track: @@ -237,30 +237,36 @@ class AudioSelection(Screen, ConfigListScreen): elif self.focus == FOCUS_STREAMS: self["streams"].setIndex(0) - def keyRight(self): - if self.focus == FOCUS_CONFIG: - ConfigListScreen.keyRight(self) - elif self.focus == FOCUS_STREAMS and self["streams"].count(): + def keyRight(self, config = False): + if config or self.focus == FOCUS_CONFIG: + if self["config"].getCurrentIndex() < 3: + ConfigListScreen.keyRight(self) + elif hasattr(self, "plugincallfunc"): + self.plugincallfunc() + if self.focus == FOCUS_STREAMS and self["streams"].count() and config == False: self["streams"].setIndex(self["streams"].count()-1) def keyRed(self): - self.colorkey(0) + if self["key_red"].getBoolean(): + self.colorkey(0) def keyGreen(self): - self.colorkey(1) + if self["key_green"].getBoolean(): + self.colorkey(1) def keyYellow(self): - self.colorkey(2) - + if self["key_yellow"].getBoolean(): + self.colorkey(2) + def keyBlue(self): - pass - + if self["key_blue"].getBoolean(): + self.colorkey(3) + def colorkey(self, idx): self["config"].setCurrentIndex(idx) - ConfigListScreen.keyRight(self) + self.keyRight(True) def keyUp(self): - print "[keyUp]", self["streams"].getIndex() if self.focus == FOCUS_CONFIG: self["config"].instance.moveSelection(self["config"].instance.moveUp) elif self.focus == FOCUS_STREAMS: @@ -273,7 +279,6 @@ class AudioSelection(Screen, ConfigListScreen): self["streams"].selectPrevious() def keyDown(self): - print "[keyDown]", self["config"].getCurrentIndex(), len(self["config"].getList())-1 if self.focus == FOCUS_CONFIG: if self["config"].getCurrentIndex() < len(self["config"].getList())-1: self["config"].instance.moveSelection(self["config"].instance.moveDown) @@ -285,13 +290,12 @@ class AudioSelection(Screen, ConfigListScreen): self["streams"].selectNext() def keyOk(self): - print "[keyok]", self["streams"].list, self["streams"].getCurrent() if self.focus == FOCUS_STREAMS and self["streams"].list: cur = self["streams"].getCurrent() - if self.settings.menupage.getValue() == "audio" and cur[0] is not None: + if self.settings.menupage.getValue() == PAGE_AUDIO and cur[0] is not None: self.changeAudio(cur[2]) self.__updatedInfo() - if self.settings.menupage.getValue() == "subtitles" and cur[0] is not None: + if self.settings.menupage.getValue() == PAGE_SUBTITLES and cur[0] is not None: if self.infobar.selected_subtitle == cur[0]: self.enableSubtitle(None) selectedidx = self["streams"].getIndex() @@ -300,9 +304,14 @@ class AudioSelection(Screen, ConfigListScreen): else: self.enableSubtitle(cur[0]) self.__updatedInfo() - #self.close() + self.close(0) elif self.focus == FOCUS_CONFIG: self.keyRight() def cancel(self): - self.close() + self.close(0) + +class SubtitleSelection(AudioSelection): + def __init__(self, session, infobar=None): + AudioSelection.__init__(self, session, infobar, page=PAGE_SUBTITLES) + self.skinName = ["AudioSelection"]