from Screen import Screen
from Components.ServiceEventTracker import ServiceEventTracker
-from Components.ActionMap import ActionMap
+from Components.ActionMap import NumberActionMap
from Components.ConfigList import ConfigListScreen
from Components.ChoiceList import ChoiceList, ChoiceEntryComponent
from Components.config import config, ConfigSubsection, getConfigListEntry, ConfigNothing, ConfigSelection, ConfigOnOff
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([])
self.cached_subtitle_checked = False
self.__selected_subtitle = None
- self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
+ self["actions"] = NumberActionMap(["ColorActions", "SetupActions", "DirectionActions"],
{
"red": self.keyRed,
"green": self.keyGreen,
"cancel": self.cancel,
"up": self.keyUp,
"down": self.keyDown,
- }, -3)
+ "1": self.keyNumberGlobal,
+ "2": self.keyNumberGlobal,
+ "3": self.keyNumberGlobal,
+ "4": self.keyNumberGlobal,
+ "5": self.keyNumberGlobal,
+ "6": self.keyNumberGlobal,
+ "7": self.keyNumberGlobal,
+ "8": self.keyNumberGlobal,
+ "9": self.keyNumberGlobal,
+ }, -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))
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"].setBoolean(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)
+ number = str(x + 1)
i = audio.getTrackInfo(x)
languages = i.getLanguage().split('/')
description = i.getDescription() or _("<unknown>")
else:
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(('',))
+ conflist.append(('',))
self["key_red"].setBoolean(False)
- conflist.append(getConfigListEntry("", self.settings.dummy))
self["key_green"].setBoolean(False)
if self.subtitlesEnabled():
language = _("<unknown>")
selected = ""
- if sel and x[:4] == sel[:4]:
+ if sel and x == sel:
selected = _("Running")
selectedidx = idx
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 = (_("<unknown>"), "UTF-8 text", "SSA", "AAS", ".SRT file", "VOB", "PGS (unsupported)")
description = types[x[2]]
streams.append((x, "", number, description, language, selected))
self.fnc(*self.args)
Plugins = [ (p.name, PluginCaller(self.infobar.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ]
-
- print "Plugins", Plugins
- self.settings.dummy = ConfigNothing()
if len(Plugins):
self["key_blue"].setBoolean(True)
- conflist.append(getConfigListEntry(Plugins[0][0], self.settings.dummy))
+ 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)
- print "setting self[streams].list:", streams
self["streams"].list = streams
- print "setting self[streams].setIndex:", selectedidx
self["streams"].setIndex(selectedidx)
- print "debug1"
def __updatedInfo(self):
self.fillList()
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
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:
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:
ConfigListScreen.keyRight(self)
elif hasattr(self, "plugincallfunc"):
self.plugincallfunc()
- if self.focus == FOCUS_STREAMS and self["streams"].count():
+ if self.focus == FOCUS_STREAMS and self["streams"].count() and config == False:
self["streams"].setIndex(self["streams"].count()-1)
def keyRed(self):
def keyBlue(self):
if self["key_blue"].getBoolean():
- print "colorkey(3)"
self.colorkey(3)
def colorkey(self, idx):
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:
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)
elif self.focus == FOCUS_STREAMS:
self["streams"].selectNext()
+ def keyNumberGlobal(self, number):
+ if number <= len(self["streams"].list):
+ self["streams"].setIndex(number-1)
+ self.keyOk()
+
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:
- self.changeAudio(cur[2])
+ if self.settings.menupage.getValue() == PAGE_AUDIO and cur[0] is not None:
+ self.changeAudio(cur[0])
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()
else:
self.enableSubtitle(cur[0])
self.__updatedInfo()
- #self.close()
+ self.close(0)
elif self.focus == FOCUS_CONFIG:
self.keyRight()
def cancel(self):
self.close(0)
+
+class SubtitleSelection(AudioSelection):
+ def __init__(self, session, infobar=None):
+ AudioSelection.__init__(self, session, infobar, page=PAGE_SUBTITLES)
+ self.skinName = ["AudioSelection"]