X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/84702da5d3a6df33717b399b859008a3cf8a1522..40c7c611cfab3dfe403a041e4921805cb107adf4:/lib/python/Screens/InfoBarGenerics.py diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 7c335f1d..36f1d90c 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -13,7 +13,7 @@ from Components.PluginComponent import plugins from Components.ProgressBar import * from Components.ServiceEventTracker import ServiceEventTracker from Components.ServiceName import ServiceName -from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean +from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean, configSelection, configElement_nonSave, getConfigListEntry from Components.config import configfile, configsequencearg from Components.TimerList import TimerEntryComponent from Components.TunerInfo import TunerInfo @@ -30,6 +30,7 @@ from Screens.MessageBox import MessageBox from Screens.MinuteInput import MinuteInput from Screens.TimerSelection import TimerSelection from Screens.PictureInPicture import PictureInPicture +from Screens.SubtitleDisplay import SubtitleDisplay from ServiceReference import ServiceReference from Tools import Notifications @@ -257,7 +258,8 @@ class InfoBarChannelSelection: "zapUp": (self.zapUp, _("previous channel")), "zapDown": (self.zapDown, _("next channel")), "historyBack": (self.historyBack, _("previous channel in history")), - "historyNext": (self.historyNext, _("next channel in history")) + "historyNext": (self.historyNext, _("next channel in history")), + "openServiceList": (self.openServiceList, _("open service list")), }) def firstRun(self): @@ -265,7 +267,7 @@ class InfoBarChannelSelection: config.misc.initialchannelselection.value = 0 config.misc.initialchannelselection.save() self.switchChannelDown() - + def historyBack(self): self.servicelist.historyBack() @@ -279,6 +281,9 @@ class InfoBarChannelSelection: def switchChannelDown(self): self.servicelist.moveDown() self.session.execDialog(self.servicelist) + + def openServiceList(self): + self.session.execDialog(self.servicelist) def zapUp(self): if currentConfigSelectionElement(config.usage.quickzap_bouquet_change) == "yes": @@ -408,8 +413,8 @@ class InfoBarEPG: self.eventView = None if ret: dlgs=len(self.dlg_stack) - assert dlgs>0 - self.dlg_stack[dlgs-1].close(dlgs > 1) + if dlgs > 0: + self.dlg_stack[dlgs-1].close(dlgs > 1) def openMultiServiceEPG(self, withCallback=True): bouquets = self.servicelist.getBouquetList() @@ -448,7 +453,8 @@ class InfoBarEPG: if self.is_now_next and len(self.dlg_stack) == 1: self.getNowNext() assert self.eventView - self.eventView.setEvent(self.epglist[0]) + if len(self.epglist): + self.eventView.setEvent(self.epglist[0]) def openEventView(self): ref = self.session.nav.getCurrentlyPlayingServiceReference() @@ -679,6 +685,8 @@ class InfoBarSeek: def unPauseService(self): print "unpause" + if self.seekstate == self.SEEK_STATE_PLAY: + return 0 self.setSeekState(self.SEEK_STATE_PLAY); def doSeek(self, seektime): @@ -1015,39 +1023,56 @@ class InfoBarExtensions: { "extensions": (self.extensions, "Extensions..."), }) - + + PIPON = 0 + PIPOFF = 1 + MOVEPIP = 2 + PIPSWAP = 3 + ENABLE_SUBTITLE = 4 + def extensions(self): list = [] if self.pipshown == False: - list.append((_("Activate Picture in Picture"), "pipon")) + list.append((_("Activate Picture in Picture"), self.PIPON)) elif self.pipshown == True: - list.append((_("Disable Picture in Picture"), "pipoff")) - list.append((_("Move Picture in Picture"), "movepip")) + 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() + l = s and s.getSubtitleList() or [ ] + + for x in l: + list.append(("DEBUG: Enable Subtitles: " + x[0], self.ENABLE_SUBTITLE, x[1])) + self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list) def extensionCallback(self, answer): if answer is not None: - if answer[1] == "pipon": - self.session.nav.stopService() + if answer[1] == self.PIPON: self.pip = self.session.instantiateDialog(PictureInPicture) - #self.pip.show() newservice = self.session.nav.getCurrentlyPlayingServiceReference() - self.pipservice = eServiceCenter.getInstance().play(newservice) - if self.pipservice and not self.pipservice.setTarget(1): - self.pipservice.start() + + if self.pip.playService(newservice): self.pipshown = True else: - self.pipservice = None + self.pipshown = False del self.pip self.session.nav.playService(newservice) - elif answer[1] == "pipoff": - #self.pip.hide() - self.pipservice = None + elif answer[1] == self.PIPOFF: del self.pip self.pipshown = False - elif answer[1] == "movepip": + elif answer[1] == self.PIPSWAP: + swapservice = self.pip.getCurrentService() + self.pip.playService(self.session.nav.getCurrentlyPlayingServiceReference()) + self.session.nav.playService(swapservice) + + 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 @@ -1187,14 +1212,18 @@ class InfoBarAudioSelection: def audioSelection(self): service = self.session.nav.getCurrentService() audio = service.audioTracks() - self.audio = audio + self.audioTracks = audio n = audio.getNumberOfTracks() + keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n + tlist = [] + print "tlist:", tlist if n > 0: - tlist = [] + self.audioChannel = service.audioChannel() + for x in range(n): i = audio.getTrackInfo(x) language = i.getLanguage() - description = i.getDescription(); + description = i.getDescription() if len(language) == 3: if language in LanguageCodes: @@ -1209,33 +1238,98 @@ class InfoBarAudioSelection: selectedAudio = tlist[0][1] tlist.sort(lambda x,y : cmp(x[0], y[0])) - selection = 0 + + selection = 2 for x in tlist: if x[1] != selectedAudio: selection += 1 else: break - - self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection) + + tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist + self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys) + else: + del self.audioTracks def audioSelected(self, audio): if audio is not None: - self.audio.selectTrack(audio[1]) + if isinstance(audio[1], str): + if audio[1] == "mode": + keys = ["red", "green", "yellow"] + selection = self.audioChannel.getCurrentChannel() + tlist = [(_("left"), 0), (_("stereo"), 1), (_("right"), 2)] + self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys) + else: + del self.audioChannel + if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]: + self.audioTracks.selectTrack(audio[1]) + else: + del self.audioChannel + del self.audioTracks + + def modeSelected(self, mode): + if mode is not None: + self.audioChannel.selectChannel(mode[1]) + del self.audioChannel class InfoBarSubserviceSelection: def __init__(self): self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions", { - "subserviceSelection": (self.subserviceSelection, "Subservice list..."), + "subserviceSelection": (self.subserviceSelection, _("Subservice list...")), }) + self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions", + { + "nextSubservice": (self.nextSubservice, _("Switch to next subservice")), + "prevSubservice": (self.prevSubservice, _("Switch to previous subservice")) + }, -1) + self["SubserviceQuickzapAction"].setEnabled(False) + + self.session.nav.event.append(self.checkSubservicesAvail) # we like to get service events + + def checkSubservicesAvail(self, ev): + if ev == iPlayableService.evUpdatedEventInfo: + service = self.session.nav.getCurrentService() + subservices = service and service.subServices() + if not subservices or subservices.getNumberOfSubservices() == 0: + self["SubserviceQuickzapAction"].setEnabled(False) + + def nextSubservice(self): + self.changeSubservice(+1) + + def prevSubservice(self): + self.changeSubservice(-1) + + def changeSubservice(self, direction): + service = self.session.nav.getCurrentService() + subservices = service and service.subServices() + n = subservices and subservices.getNumberOfSubservices() + if n and n > 0: + selection = -1 + ref = self.session.nav.getCurrentlyPlayingServiceReference() + for x in range(n): + if subservices.getSubservice(x).toString() == ref.toString(): + selection = x + if selection != -1: + selection += direction + if selection >= n: + selection=0 + elif selection < 0: + selection=n-1 + newservice = subservices.getSubservice(selection) + if newservice.valid(): + del subservices + del service + self.session.nav.playService(newservice) + def subserviceSelection(self): service = self.session.nav.getCurrentService() - subservices = service.subServices() + subservices = service and service.subServices() - n = subservices.getNumberOfSubservices() + n = subservices and subservices.getNumberOfSubservices() selection = 0 - if n > 0: + if n and n > 0: ref = self.session.nav.getCurrentlyPlayingServiceReference() tlist = [] for x in range(n): @@ -1248,6 +1342,7 @@ class InfoBarSubserviceSelection: def subserviceSelected(self, service): if not service is None: + self["SubserviceQuickzapAction"].setEnabled(True) self.session.nav.playService(service[1]) class InfoBarAdditionalInfo: @@ -1348,6 +1443,10 @@ class InfoBarNotifications: def __init__(self): self.onExecBegin.append(self.checkNotifications) Notifications.notificationAdded.append(self.checkNotificationsIfExecing) + self.onClose.append(self.__removeNotification) + + def __removeNotification(self): + Notifications.notificationAdded.remove(self.checkNotificationsIfExecing) def checkNotificationsIfExecing(self): if self.execing: @@ -1357,12 +1456,11 @@ class InfoBarNotifications: if len(Notifications.notifications): n = Notifications.notifications[0] Notifications.notifications = Notifications.notifications[1:] - print "open",n cb = n[0] if cb is not None: - self.session.openWithCallback(cb, *n[1:]) + self.session.openWithCallback(cb, n[1], *n[2], **n[3]) else: - self.session.open(*n[1:]) + self.session.open(n[1], *n[2], **n[3]) class InfoBarServiceNotifications: def __init__(self): @@ -1535,3 +1633,50 @@ class InfoBarTeletextPlugin: def startTeletext(self): self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService()) + +class InfoBarSubtitleSupport(object): + def __init__(self): + object.__init__(self) + self.subtitle_window = self.session.instantiateDialog(SubtitleDisplay) + self.__subtitles_enabled = False + + self.__event_tracker = ServiceEventTracker(screen=self, eventmap= + { + iPlayableService.evStart: self.__serviceStarted, + }) + + def __serviceStarted(self): + # reenable if it was enabled + r = self.__subtitles_enabled + self.__subtitles_enabled = False + self.__selected_subtitle = None + self.setSubtitlesEnable(r) + + def getCurrentServiceSubtitle(self): + service = self.session.nav.getCurrentService() + return service and service.subtitle() + + def setSubtitlesEnable(self, enable=True): + subtitle = self.getCurrentServiceSubtitle() + if enable and self.__selected_subtitle: + if subtitle and not self.__subtitles_enabled: + subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle) + self.subtitle_window.show() + self.__subtitles_enabled = True + else: + if subtitle: + subtitle.disableSubtitles(self.subtitle_window.instance) + + self.subtitle_window.hide() + self.__subtitles_enabled = False + + def setSelectedSubtitle(self, subtitle): + if self.__selected_subtitle != subtitle and self.subtitles_enabled: + # kick + self.__selected_subtitle = subtitle + self.__serviceStarted() + else: + self.__selected_subtitle = subtitle + + subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable) + selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle)