add subtitle support, though still disabled in dvb service
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 5 Jun 2006 21:23:54 +0000 (21:23 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 5 Jun 2006 21:23:54 +0000 (21:23 +0000)
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py

index 80ab0ef..5669a77 100644 (file)
@@ -18,7 +18,8 @@ from Screens.InfoBarGenerics import InfoBarShowHide, \
        InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
        InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
        InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
        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
 
 
 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,
        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)
 
        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, \
                                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...")]))
                        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,
                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)
                
        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, \
                                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)
                        x.__init__(self)
 
                self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
index 2f7b36c..948ecbf 100644 (file)
@@ -1022,6 +1022,7 @@ class InfoBarExtensions:
        PIPOFF = 1
        MOVEPIP = 2
        PIPSWAP = 3
        PIPOFF = 1
        MOVEPIP = 2
        PIPSWAP = 3
+       ENABLE_SUBTITLE = 4
 
        def extensions(self):
                list = []
 
        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))
                        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):
                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.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
 
 
 from RecordTimer import parseEvent
 
@@ -1617,6 +1627,7 @@ class InfoBarSubtitleSupport(object):
                # reenable if it was enabled
                r = self.__subtitles_enabled
                self.__subtitles_enabled = False
                # reenable if it was enabled
                r = self.__subtitles_enabled
                self.__subtitles_enabled = False
+               self.__selected_subtitle = None
                self.setSubtitlesEnable(r)
 
        def getCurrentServiceSubtitle(self):
                self.setSubtitlesEnable(r)
 
        def getCurrentServiceSubtitle(self):
@@ -1625,9 +1636,9 @@ class InfoBarSubtitleSupport(object):
        
        def setSubtitlesEnable(self, enable=True):
                subtitle = self.getCurrentServiceSubtitle()
        
        def setSubtitlesEnable(self, enable=True):
                subtitle = self.getCurrentServiceSubtitle()
-               if enable:
+               if enable and self.__selected_subtitle:
                        if subtitle and not self.__subtitles_enabled:
                        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:
                                self.subtitle_window.show()
                                self.__subtitles_enabled = True
                else:
@@ -1636,5 +1647,14 @@ class InfoBarSubtitleSupport(object):
 
                        self.subtitle_window.hide()
                        self.__subtitles_enabled = False
 
                        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)