use NumericalTextInput to jump to entries in ChannelSelection (jumping needs to imple...
[enigma2.git] / lib / python / Screens / AudioSelection.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.MenuList import MenuList
4 from Components.Label import Label
5 from Tools.ISO639 import LanguageCodes
6
7 class AudioSelection(Screen):
8         def KeyOk(self):
9                 selection = self["tracks"].getCurrent()
10                 print "select track " + str(selection[1])
11                 
12                 self.audio.selectTrack(selection[1])
13                 self.close()
14         def __init__(self, session, audio):
15                 Screen.__init__(self, session)
16
17                 self["actions"] = ActionMap(["OkCancelActions"], 
18                         {
19                                 "cancel": self.close,
20                                 "ok": self.KeyOk,
21                         })
22
23                 self.audio = audio
24
25                 tlist = []
26                 n = audio.getNumberOfTracks()
27                 for x in range(n):
28                         i = audio.getTrackInfo(x)
29                         langCode = i.getLanguage()
30                         
31                         description = i.getDescription();
32                         
33                         if langCode in LanguageCodes:
34                                 language = LanguageCodes[langCode][0]
35                                 if len(description):
36                                         description += " (" + language + ")"
37                                 else:
38                                         description = language
39
40                         tlist.append((description, x))
41
42                 self["tracks"] = MenuList(tlist)