Enigma2 plugin to to play various online streams (mostly Latvian).

AudioSelection.py 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. from Screen import Screen
  2. from Screens.Setup import getConfigMenuItem, Setup
  3. from Screens.InputBox import PinInput
  4. from Screens.MessageBox import MessageBox
  5. from Components.ServiceEventTracker import ServiceEventTracker
  6. from Components.ActionMap import NumberActionMap
  7. from Components.ConfigList import ConfigListScreen
  8. from Components.config import config, ConfigSubsection, getConfigListEntry, ConfigNothing, ConfigSelection, ConfigOnOff
  9. from Components.Label import Label
  10. from Components.Pixmap import Pixmap
  11. from Components.Sources.StaticText import StaticText
  12. from Components.Sources.List import List
  13. from Components.Sources.Boolean import Boolean
  14. from Components.SystemInfo import SystemInfo
  15. from Components.VolumeControl import VolumeControl
  16. from enigma import iPlayableService, eTimer, eSize
  17. from Tools.ISO639 import LanguageCodes
  18. from Tools.BoundFunction import boundFunction
  19. FOCUS_CONFIG, FOCUS_STREAMS = range(2)
  20. [PAGE_AUDIO, PAGE_SUBTITLES] = ["audio", "subtitles"]
  21. class AudioSelection(Screen, ConfigListScreen):
  22. def __init__(self, session, infobar=None, page=PAGE_AUDIO):
  23. Screen.__init__(self, session)
  24. self["streams"] = List([], enableWrapAround=True)
  25. self["key_red"] = Boolean(False)
  26. self["key_green"] = Boolean(False)
  27. self["key_yellow"] = Boolean(True)
  28. self["key_blue"] = Boolean(False)
  29. self["key_left"] = Pixmap()
  30. self["key_right"] = Pixmap()
  31. self["switchdescription"] = Label(_("Switch between Audio-, Subtitlepage"))
  32. self["summary_description"] = StaticText("")
  33. self.protectContextMenu = True
  34. ConfigListScreen.__init__(self, [])
  35. self.infobar = infobar or self.session.infobar
  36. self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
  37. {
  38. iPlayableService.evUpdatedInfo: self.__updatedInfo
  39. })
  40. self.cached_subtitle_checked = False
  41. self.__selected_subtitle = None
  42. self["actions"] = NumberActionMap(["ColorActions", "OkCancelActions", "DirectionActions", "MenuActions", "InfobarAudioSelectionActions", "InfobarSubtitleSelectionActions"],
  43. {
  44. "red": self.keyRed,
  45. "green": self.keyGreen,
  46. "yellow": self.keyYellow,
  47. "subtitleSelection": self.keyAudioSubtitle,
  48. "audioSelection": self.keyAudioSubtitle,
  49. "blue": self.keyBlue,
  50. "ok": self.keyOk,
  51. "cancel": self.cancel,
  52. "up": self.keyUp,
  53. "down": self.keyDown,
  54. "volumeUp": self.volumeUp,
  55. "volumeDown": self.volumeDown,
  56. "volumeMute": self.volumeMute,
  57. "menu": self.openAutoLanguageSetup,
  58. "1": self.keyNumberGlobal,
  59. "2": self.keyNumberGlobal,
  60. "3": self.keyNumberGlobal,
  61. "4": self.keyNumberGlobal,
  62. "5": self.keyNumberGlobal,
  63. "6": self.keyNumberGlobal,
  64. "7": self.keyNumberGlobal,
  65. "8": self.keyNumberGlobal,
  66. "9": self.keyNumberGlobal,
  67. }, -2)
  68. self.settings = ConfigSubsection()
  69. choicelist = [(PAGE_AUDIO,""), (PAGE_SUBTITLES,"")]
  70. self.settings.menupage = ConfigSelection(choices = choicelist, default=page)
  71. self.onLayoutFinish.append(self.__layoutFinished)
  72. def __layoutFinished(self):
  73. self["config"].instance.setSelectionEnable(False)
  74. self.focus = FOCUS_STREAMS
  75. self.settings.menupage.addNotifier(self.fillList)
  76. def fillList(self, arg=None):
  77. streams = []
  78. conflist = []
  79. selectedidx = 0
  80. self["key_red"].setBoolean(False)
  81. self["key_green"].setBoolean(False)
  82. self["key_yellow"].setBoolean(False)
  83. self["key_blue"].setBoolean(False)
  84. service = self.session.nav.getCurrentService()
  85. self.audioTracks = audio = service and service.audioTracks()
  86. n = audio and audio.getNumberOfTracks() or 0
  87. subtitlelist = self.getSubtitleList()
  88. if self.settings.menupage.value == PAGE_AUDIO:
  89. self.setTitle(_("Select audio track"))
  90. service = self.session.nav.getCurrentService()
  91. self.audioTracks = audio = service and service.audioTracks()
  92. n = audio and audio.getNumberOfTracks() or 0
  93. if SystemInfo["CanDownmixAC3"]:
  94. self.settings.downmix_ac3 = ConfigOnOff(default=config.av.downmix_ac3.value)
  95. self.settings.downmix_ac3.addNotifier(self.changeAC3Downmix, initial_call = False)
  96. conflist.append(getConfigListEntry(_("Digital downmix"), self.settings.downmix_ac3, None))
  97. if SystemInfo["CanDownmixAAC"]:
  98. self.settings.downmix_aac = ConfigOnOff(default=config.av.downmix_aac.value)
  99. self.settings.downmix_aac.addNotifier(self.changeAACDownmix, initial_call = False)
  100. conflist.append(getConfigListEntry(_("AAC downmix"), self.settings.downmix_aac, None))
  101. if SystemInfo["CanAACTranscode"]:
  102. choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
  103. self.settings.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
  104. self.settings.transcodeaac.addNotifier(self.setAACTranscode, initial_call = False)
  105. conflist.append(getConfigListEntry(_("AAC transcoding"), self.settings.transcodeaac, None))
  106. if SystemInfo["CanPcmMultichannel"]:
  107. self.settings.pcm_multichannel = ConfigOnOff(default=config.av.pcm_multichannel.value)
  108. self.settings.pcm_multichannel.addNotifier(self.changePCMMultichannel, initial_call = False)
  109. conflist.append(getConfigListEntry(_("PCM Multichannel"), self.settings.pcm_multichannel, None))
  110. if n > 0:
  111. self.audioChannel = service.audioChannel()
  112. if self.audioChannel:
  113. choicelist = [("0",_("left")), ("1",_("stereo")), ("2", _("right"))]
  114. self.settings.channelmode = ConfigSelection(choices = choicelist, default = str(self.audioChannel.getCurrentChannel()))
  115. self.settings.channelmode.addNotifier(self.changeMode, initial_call = False)
  116. conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode, None))
  117. selectedAudio = self.audioTracks.getCurrentTrack()
  118. for x in range(n):
  119. number = str(x + 1)
  120. i = audio.getTrackInfo(x)
  121. languages = i.getLanguage().split('/')
  122. description = i.getDescription() or ""
  123. selected = ""
  124. language = ""
  125. if selectedAudio == x:
  126. selected = "X"
  127. selectedidx = x
  128. cnt = 0
  129. for lang in languages:
  130. if cnt:
  131. language += ' / '
  132. if LanguageCodes.has_key(lang):
  133. language += _(LanguageCodes[lang][0])
  134. else:
  135. language += lang
  136. cnt += 1
  137. streams.append((x, "", number, description, language, selected))
  138. else:
  139. conflist.append(('',))
  140. if SystemInfo["Can3DSurround"]:
  141. choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
  142. self.settings.surround_3d = ConfigSelection(choices = choice_list, default = config.av.surround_3d.value)
  143. self.settings.surround_3d.addNotifier(self.change3DSurround, initial_call = False)
  144. conflist.append(getConfigListEntry(_("3D Surround"), self.settings.surround_3d, None))
  145. if SystemInfo["Can3DSpeaker"] and config.av.surround_3d.value != "none":
  146. choice_list = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
  147. self.settings.surround_3d_speaker = ConfigSelection(choices = choice_list, default = config.av.surround_3d_speaker.value)
  148. self.settings.surround_3d_speaker.addNotifier(self.change3DSurroundSpeaker, initial_call = False)
  149. conflist.append(getConfigListEntry(_("3D Surround Speaker Position"), self.settings.surround_3d_speaker, None))
  150. if SystemInfo["CanAutoVolume"]:
  151. choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
  152. self.settings.autovolume = ConfigSelection(choices = choice_list, default = config.av.autovolume.value)
  153. self.settings.autovolume.addNotifier(self.changeAutoVolume, initial_call = False)
  154. conflist.append(getConfigListEntry(_("Auto Volume Level"), self.settings.autovolume, None))
  155. if SystemInfo["Canedidchecking"]:
  156. choice_list = [("00000001", _("on")), ("00000000", _("off"))]
  157. self.settings.bypass_edid_checking = ConfigSelection(choices = choice_list, default = config.av.bypass_edid_checking.value)
  158. self.settings.bypass_edid_checking.addNotifier(self.changeEDIDChecking, initial_call = False)
  159. conflist.append(getConfigListEntry(_("Bypass HDMI EDID Check"), self.settings.bypass_edid_checking, None))
  160. from Components.PluginComponent import plugins
  161. from Plugins.Plugin import PluginDescriptor
  162. if hasattr(self.infobar, "runPlugin"):
  163. class PluginCaller:
  164. def __init__(self, fnc, *args):
  165. self.fnc = fnc
  166. self.args = args
  167. def __call__(self, *args, **kwargs):
  168. self.fnc(*self.args)
  169. Plugins = [ (p.name, PluginCaller(self.infobar.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ]
  170. if len(Plugins):
  171. for x in Plugins:
  172. if x[0] != 'AudioEffect': # always make AudioEffect Blue button.
  173. conflist.append(getConfigListEntry(x[0], ConfigNothing(),x[1]))
  174. elif self.settings.menupage.value == PAGE_SUBTITLES:
  175. self.setTitle(_("Subtitle selection"))
  176. idx = 0
  177. for x in subtitlelist:
  178. number = str(x[1])
  179. description = "?"
  180. language = ""
  181. selected = ""
  182. if self.selectedSubtitle and x[:4] == self.selectedSubtitle[:4]:
  183. selected = "X"
  184. selectedidx = idx
  185. try:
  186. if x[4] != "und":
  187. if LanguageCodes.has_key(x[4]):
  188. language = _(LanguageCodes[x[4]][0])
  189. else:
  190. language = x[4]
  191. except:
  192. language = ""
  193. if x[0] == 0:
  194. description = "DVB"
  195. number = "%x" % (x[1])
  196. elif x[0] == 1:
  197. description = "teletext"
  198. number = "%x%02x" %(x[3] and x[3] or 8, x[2])
  199. elif x[0] == 2:
  200. types = ("unknown", "embedded", "SSA file", "ASS file",
  201. "SRT file", "VOB file", "PGS file")
  202. try:
  203. description = types[x[2]]
  204. except:
  205. description = _("unknown") + ": %s" % x[2]
  206. number = str(int(number) + 1)
  207. streams.append((x, "", number, description, language, selected))
  208. idx += 1
  209. if self.infobar.selected_subtitle and self.infobar.selected_subtitle != (0,0,0,0) and not ".DVDPlayer'>" in `self.infobar`:
  210. conflist.append(getConfigListEntry(_("Subtitle Quickmenu"), ConfigNothing(), None))
  211. if len(conflist) > 0 and conflist[0][0]:
  212. self["key_red"].setBoolean(True)
  213. if len(conflist) > 1 and conflist[1][0]:
  214. self["key_green"].setBoolean(True)
  215. if len(conflist) > 2 and conflist[2][0]:
  216. self["key_yellow"].setBoolean(True)
  217. if len(conflist) > 3 and conflist[3][0]:
  218. self["key_blue"].setBoolean(True)
  219. self["config"].list = conflist
  220. self["config"].l.setList(conflist)
  221. self["streams"].list = streams
  222. self["streams"].setIndex(selectedidx)
  223. def __updatedInfo(self):
  224. self.fillList()
  225. def getSubtitleList(self):
  226. service = self.session.nav.getCurrentService()
  227. subtitle = service and service.subtitle()
  228. subtitlelist = subtitle and subtitle.getSubtitleList()
  229. self.selectedSubtitle = None
  230. if self.subtitlesEnabled():
  231. self.selectedSubtitle = self.infobar.selected_subtitle
  232. if self.selectedSubtitle and self.selectedSubtitle[:4] == (0,0,0,0):
  233. self.selectedSubtitle = None
  234. elif self.selectedSubtitle and not self.selectedSubtitle[:4] in (x[:4] for x in subtitlelist):
  235. subtitlelist.append(self.selectedSubtitle)
  236. return subtitlelist
  237. def subtitlesEnabled(self):
  238. try:
  239. return self.infobar.subtitle_window.shown
  240. except:
  241. return False
  242. def enableSubtitle(self, subtitle):
  243. if self.infobar.selected_subtitle != subtitle:
  244. self.infobar.enableSubtitle(subtitle)
  245. def change3DSurround(self, surround_3d):
  246. if surround_3d.value:
  247. config.av.surround_3d.value = surround_3d.value
  248. config.av.surround_3d.save()
  249. self.fillList()
  250. def change3DSurroundSpeaker(self, surround_3d_speaker):
  251. if surround_3d_speaker.value:
  252. config.av.surround_3d_speaker.value = surround_3d_speaker.value
  253. config.av.surround_3d_speaker.save()
  254. def changeAutoVolume(self, autovolume):
  255. if autovolume.value:
  256. config.av.autovolume.value = autovolume.value
  257. config.av.autovolume.save()
  258. def changeEDIDChecking(self, edidchecking):
  259. if edidchecking.value:
  260. config.av.bypass_edid_checking.value = edidchecking.value
  261. config.av.bypass_edid_checking.save()
  262. def changeAC3Downmix(self, downmix):
  263. if downmix.value:
  264. config.av.downmix_ac3.setValue(True)
  265. if SystemInfo["supportPcmMultichannel"]:
  266. config.av.pcm_multichannel.setValue(False)
  267. else:
  268. config.av.downmix_ac3.setValue(False)
  269. config.av.downmix_ac3.save()
  270. if SystemInfo["supportPcmMultichannel"]:
  271. config.av.pcm_multichannel.save()
  272. self.fillList()
  273. def changePCMMultichannel(self, multichan):
  274. if multichan.value:
  275. config.av.pcm_multichannel.setValue(True)
  276. else:
  277. config.av.pcm_multichannel.setValue(False)
  278. config.av.pcm_multichannel.save()
  279. self.fillList()
  280. def changeAACDownmix(self, downmix):
  281. if downmix.value:
  282. config.av.downmix_aac.setValue(True)
  283. else:
  284. config.av.downmix_aac.setValue(False)
  285. config.av.downmix_aac.save()
  286. def setAACTranscode(self, transcode):
  287. config.av.transcodeaac.setValue(transcode)
  288. config.av.transcodeaac.save()
  289. def changeMode(self, mode):
  290. if mode is not None and self.audioChannel:
  291. self.audioChannel.selectChannel(int(mode.value))
  292. def changeAudio(self, audio):
  293. track = int(audio)
  294. if isinstance(track, int):
  295. if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > track:
  296. self.audioTracks.selectTrack(track)
  297. def keyLeft(self):
  298. if self.focus == FOCUS_CONFIG:
  299. ConfigListScreen.keyLeft(self)
  300. elif self.focus == FOCUS_STREAMS:
  301. self.keyAudioSubtitle()
  302. def keyRight(self, config = False):
  303. if config or self.focus == FOCUS_CONFIG:
  304. if self.settings.menupage.value == PAGE_AUDIO and self["config"].getCurrent()[2]:
  305. self["config"].getCurrent()[2]()
  306. elif self.settings.menupage.value == PAGE_SUBTITLES and self.infobar.selected_subtitle and self.infobar.selected_subtitle != (0,0,0,0):
  307. self.session.open(QuickSubtitlesConfigMenu, self.infobar)
  308. else:
  309. ConfigListScreen.keyRight(self)
  310. if self.focus == FOCUS_STREAMS and config == False:
  311. self.keyAudioSubtitle()
  312. def keyRed(self):
  313. if self["key_red"].getBoolean():
  314. self.colorkey(0)
  315. else:
  316. return 0
  317. def keyGreen(self):
  318. if self["key_green"].getBoolean():
  319. self.colorkey(1)
  320. else:
  321. return 0
  322. def keyYellow(self):
  323. if self["key_yellow"].getBoolean():
  324. self.colorkey(2)
  325. else:
  326. return 0
  327. def keyBlue(self):
  328. if self["key_blue"].getBoolean():
  329. self.colorkey(3)
  330. else:
  331. return 0
  332. def keyAudioSubtitle(self):
  333. if self.settings.menupage.value == PAGE_AUDIO:
  334. self.settings.menupage.setValue('subtitles')
  335. else:
  336. self.settings.menupage.setValue('audio')
  337. def colorkey(self, idx):
  338. self["config"].setCurrentIndex(idx)
  339. self.keyRight(True)
  340. def keyUp(self):
  341. if self.focus == FOCUS_CONFIG:
  342. self["config"].instance.moveSelection(self["config"].instance.moveUp)
  343. elif self.focus == FOCUS_STREAMS:
  344. if self["streams"].getIndex() == 0:
  345. self["switchdescription"].hide()
  346. self["key_left"].hide()
  347. self["key_right"].hide()
  348. self["config"].instance.setSelectionEnable(True)
  349. self["streams"].style = "notselected"
  350. self["config"].setCurrentIndex(len(self["config"].getList())-1)
  351. self.focus = FOCUS_CONFIG
  352. else:
  353. self["streams"].selectPrevious()
  354. def keyDown(self):
  355. if self.focus == FOCUS_CONFIG:
  356. if self["config"].getCurrentIndex() < len(self["config"].getList())-1:
  357. self["config"].instance.moveSelection(self["config"].instance.moveDown)
  358. else:
  359. self["switchdescription"].show()
  360. self["key_left"].show()
  361. self["key_right"].show()
  362. self["config"].instance.setSelectionEnable(False)
  363. self["streams"].style = "default"
  364. self.focus = FOCUS_STREAMS
  365. elif self.focus == FOCUS_STREAMS:
  366. self["streams"].selectNext()
  367. def volumeUp(self):
  368. VolumeControl.instance and VolumeControl.instance.volUp()
  369. def volumeDown(self):
  370. VolumeControl.instance and VolumeControl.instance.volDown()
  371. def volumeMute(self):
  372. VolumeControl.instance and VolumeControl.instance.volMute()
  373. def keyNumberGlobal(self, number):
  374. if number <= len(self["streams"].list):
  375. self["streams"].setIndex(number-1)
  376. self.keyOk()
  377. def keyOk(self):
  378. if self.focus == FOCUS_STREAMS and self["streams"].list:
  379. cur = self["streams"].getCurrent()
  380. if self.settings.menupage.value == PAGE_AUDIO and cur[0] is not None:
  381. self.changeAudio(cur[0])
  382. self.__updatedInfo()
  383. if self.settings.menupage.value == PAGE_SUBTITLES and cur[0] is not None:
  384. if self.infobar.selected_subtitle and self.infobar.selected_subtitle[:4] == cur[0][:4]:
  385. self.enableSubtitle(None)
  386. selectedidx = self["streams"].getIndex()
  387. self.__updatedInfo()
  388. self["streams"].setIndex(selectedidx)
  389. else:
  390. self.enableSubtitle(cur[0][:5])
  391. self.__updatedInfo()
  392. self.close(0)
  393. elif self.focus == FOCUS_CONFIG:
  394. self.keyRight()
  395. def openAutoLanguageSetup(self):
  396. if self.protectContextMenu and config.ParentalControl.setuppinactive.value and config.ParentalControl.config_sections.context_menus.value:
  397. self.session.openWithCallback(self.protectResult, PinInput, pinList=[x.value for x in config.ParentalControl.servicepin], triesEntry=config.ParentalControl.retries.servicepin, title=_("Please enter the correct pin code"), windowTitle=_("Enter pin code"))
  398. else:
  399. self.protectResult(True)
  400. def protectResult(self, answer):
  401. if answer:
  402. self.session.open(Setup, "autolanguagesetup")
  403. self.protectContextMenu = False
  404. elif answer is not None:
  405. self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
  406. def cancel(self):
  407. self.close(0)
  408. class SubtitleSelection(AudioSelection):
  409. def __init__(self, session, infobar=None):
  410. AudioSelection.__init__(self, session, infobar, page=PAGE_SUBTITLES)
  411. self.skinName = ["AudioSelection"]
  412. class QuickSubtitlesConfigMenu(ConfigListScreen, Screen):
  413. def __init__(self, session, infobar):
  414. Screen.__init__(self, session)
  415. self.infobar = infobar or self.session.infobar
  416. self.wait = eTimer()
  417. self.wait.timeout.get().append(self.resyncSubtitles)
  418. self["videofps"] = Label("")
  419. sub = self.infobar.selected_subtitle
  420. if sub[0] == 0: # dvb
  421. menu = [
  422. getConfigMenuItem("config.subtitles.dvb_subtitles_yellow"),
  423. getConfigMenuItem("config.subtitles.dvb_subtitles_centered"),
  424. getConfigMenuItem("config.subtitles.dvb_subtitles_backtrans"),
  425. getConfigMenuItem("config.subtitles.dvb_subtitles_original_position"),
  426. getConfigMenuItem("config.subtitles.subtitle_position"),
  427. getConfigMenuItem("config.subtitles.subtitle_bad_timing_delay"),
  428. getConfigMenuItem("config.subtitles.subtitle_noPTSrecordingdelay"),
  429. ]
  430. elif sub[0] == 1: # teletext
  431. menu = [
  432. getConfigMenuItem("config.subtitles.ttx_subtitle_colors"),
  433. getConfigMenuItem("config.subtitles.ttx_subtitle_original_position"),
  434. getConfigMenuItem("config.subtitles.subtitle_fontsize"),
  435. getConfigMenuItem("config.subtitles.subtitle_position"),
  436. getConfigMenuItem("config.subtitles.subtitle_rewrap"),
  437. getConfigMenuItem("config.subtitles.subtitle_borderwidth"),
  438. getConfigMenuItem("config.subtitles.subtitle_alignment"),
  439. getConfigMenuItem("config.subtitles.subtitle_bad_timing_delay"),
  440. getConfigMenuItem("config.subtitles.subtitle_noPTSrecordingdelay"),
  441. ]
  442. else: # pango
  443. menu = [
  444. getConfigMenuItem("config.subtitles.pango_subtitles_delay"),
  445. getConfigMenuItem("config.subtitles.pango_subtitle_colors"),
  446. getConfigMenuItem("config.subtitles.pango_subtitle_fontswitch"),
  447. getConfigMenuItem("config.subtitles.colourise_dialogs"),
  448. getConfigMenuItem("config.subtitles.subtitle_fontsize"),
  449. getConfigMenuItem("config.subtitles.subtitle_position"),
  450. getConfigMenuItem("config.subtitles.subtitle_alignment"),
  451. getConfigMenuItem("config.subtitles.subtitle_rewrap"),
  452. getConfigMenuItem("config.subtitles.pango_subtitle_removehi"),
  453. getConfigMenuItem("config.subtitles.subtitle_borderwidth"),
  454. getConfigMenuItem("config.subtitles.pango_subtitles_fps"),
  455. ]
  456. self["videofps"].setText(_("Video: %s fps") % (self.getFps().rstrip(".000")))
  457. ConfigListScreen.__init__(self, menu, self.session, on_change = self.changedEntry)
  458. self["actions"] = NumberActionMap(["SetupActions"],
  459. {
  460. "cancel": self.cancel,
  461. "ok": self.ok,
  462. },-2)
  463. self.onLayoutFinish.append(self.layoutFinished)
  464. def layoutFinished(self):
  465. if not self["videofps"].text:
  466. self.instance.resize(eSize(self.instance.size().width(), self["config"].l.getItemSize().height()*len(self["config"].getList()) + 10))
  467. def changedEntry(self):
  468. if self["config"].getCurrent() in [getConfigMenuItem("config.subtitles.pango_subtitles_delay"),getConfigMenuItem("config.subtitles.pango_subtitles_fps")]:
  469. self.wait.start(500, True)
  470. def resyncSubtitles(self):
  471. self.infobar.setSeekState(self.infobar.SEEK_STATE_PAUSE)
  472. self.infobar.setSeekState(self.infobar.SEEK_STATE_PLAY)
  473. def getFps(self):
  474. from enigma import iServiceInformation
  475. service = self.session.nav.getCurrentService()
  476. info = service and service.info()
  477. if not info:
  478. return ""
  479. fps = info.getInfo(iServiceInformation.sFrameRate)
  480. if fps > 0:
  481. return "%6.3f" % (fps/1000.)
  482. return ""
  483. def cancel(self):
  484. self.close()
  485. def ok(self):
  486. config.subtitles.save()
  487. self.close()