From abefb717a04a2cbfd0216ef0618d1da5ba057d2b Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 5 Jun 2006 21:23:54 +0000 Subject: [PATCH] add subtitle support, though still disabled in dvb service --- lib/python/Screens/InfoBar.py | 12 +++++++----- lib/python/Screens/InfoBarGenerics.py | 28 +++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index 80ab0efb..5669a77a 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -18,7 +18,8 @@ from Screens.InfoBarGenerics import InfoBarShowHide, \ InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \ InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift, \ InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \ - InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions + InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \ + InfoBarSubtitleSupport from Screens.HelpMenu import HelpableScreen, HelpMenu @@ -31,7 +32,8 @@ class InfoBar(InfoBarShowHide, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek, - InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, Screen): + InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, + InfoBarSubtitleSupport, Screen): def __init__(self, session): Screen.__init__(self, session) @@ -50,7 +52,7 @@ class InfoBar(InfoBarShowHide, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \ InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \ InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \ - InfoBarTeletextPlugin, InfoBarExtensions: + InfoBarTeletextPlugin, InfoBarExtensions, InfoBarSubtitleSupport: x.__init__(self) self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")])) @@ -73,7 +75,7 @@ class MoviePlayer(InfoBarShowHide, \ InfoBarMenu, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications, InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, - InfoBarSummarySupport, InfoBarTeletextPlugin, Screen): + InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport, Screen): def __init__(self, session, service): Screen.__init__(self, session) @@ -87,7 +89,7 @@ class MoviePlayer(InfoBarShowHide, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \ InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \ InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \ - InfoBarSummarySupport, InfoBarTeletextPlugin: + InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport: x.__init__(self) self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 2f7b36c3..948ecbf6 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -1022,6 +1022,7 @@ class InfoBarExtensions: PIPOFF = 1 MOVEPIP = 2 PIPSWAP = 3 + ENABLE_SUBTITLE = 4 def extensions(self): list = [] @@ -1031,6 +1032,12 @@ class InfoBarExtensions: list.append((_("Disable Picture in Picture"), self.PIPOFF)) list.append((_("Move Picture in Picture"), self.MOVEPIP)) list.append((_("Swap services"), self.PIPSWAP)) + + s = self.getCurrentServiceSubtitle() + + for x in s.getSubtitleList(): + list.append(("DEBUG: Enable Subtitles: " + x[0], self.ENABLE_SUBTITLE, x)) + self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list) def extensionCallback(self, answer): @@ -1056,6 +1063,9 @@ class InfoBarExtensions: elif answer[1] == self.MOVEPIP: self.session.open(PiPSetup, pip = self.pip) + elif answer[1] == self.ENABLE_SUBTITLE: + self.selected_subtitle = answer[2] + self.subtitles_enabled = True from RecordTimer import parseEvent @@ -1617,6 +1627,7 @@ class InfoBarSubtitleSupport(object): # reenable if it was enabled r = self.__subtitles_enabled self.__subtitles_enabled = False + self.__selected_subtitle = None self.setSubtitlesEnable(r) def getCurrentServiceSubtitle(self): @@ -1625,9 +1636,9 @@ class InfoBarSubtitleSupport(object): def setSubtitlesEnable(self, enable=True): subtitle = self.getCurrentServiceSubtitle() - if enable: + if enable and self.__selected_subtitle: if subtitle and not self.__subtitles_enabled: - subtitle.enableSubtitles(self.subtitle_window.instance, 0) + subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle) self.subtitle_window.show() self.__subtitles_enabled = True else: @@ -1636,5 +1647,14 @@ class InfoBarSubtitleSupport(object): self.subtitle_window.hide() self.__subtitles_enabled = False - - subtitlesEnabled = property(lambda self: self.__subtitlesEnabled, setSubtitlesEnable) + + def setSelectedSubtitle(self, subtitle): + if self.__selected_subtitle != subtitle and self.subtitles_enabled: + subtitle = self.getCurrentServiceSubtitle() + + # kick + self.__serviceStarted() + self.__selected_subtitle = subtitle + + subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable) + selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle) -- 2.30.2