def setAudioTrack(service): try: from Tools.ISO639 import LanguageCodes as langC tracks = service and service.audioTracks() nTracks = tracks and tracks.getNumberOfTracks() or 0 if not nTracks: return idx = 0 trackList = [] for i in list(range(nTracks)): audioInfo = tracks.getTrackInfo(i) lang = audioInfo.getLanguage() if lang in langC: lang = langC[lang][0] desc = audioInfo.getDescription() track = idx, lang, desc idx += 1 trackList += [track] seltrack = tracks.getCurrentTrack() # we need default selected language from image # to set the audiotrack if "config.autolanguage.audio_autoselect...values" are not set from Components.International import international syslang = international.getLanguage() syslang = langC[syslang][0] if (config.autolanguage.audio_autoselect1.value or config.autolanguage.audio_autoselect2.value or config.autolanguage.audio_autoselect3.value or config.autolanguage.audio_autoselect4.value) != "---": audiolang = [config.autolanguage.audio_autoselect1.value, config.autolanguage.audio_autoselect2.value, config.autolanguage.audio_autoselect3.value, config.autolanguage.audio_autoselect4.value] caudiolang = True else: audiolang = syslang caudiolang = False useAc3 = config.autolanguage.audio_defaultac3.value if useAc3: matchedAc3 = tryAudioTrack(tracks, audiolang, caudiolang, trackList, seltrack, useAc3) if matchedAc3: return matchedMpeg = tryAudioTrack(tracks, audiolang, caudiolang, trackList, seltrack, False) if matchedMpeg: return tracks.selectTrack(0) # fallback to track 1(0) return else: matchedMpeg = tryAudioTrack(tracks, audiolang, caudiolang, trackList, seltrack, False) if matchedMpeg: return matchedAc3 = tryAudioTrack(tracks, audiolang, caudiolang, trackList, seltrack, useAc3) if matchedAc3: return tracks.selectTrack(0) # fallback to track 1(0) except Exception as e: print("[MoviePlayer] audioTrack exception:\n" + str(e))
def __init__(self): aboutInfo = getImageVersion() if aboutInfo.startswith("dev-"): self.ImageVersion = 'Experimental' else: self.ImageVersion = 'Stable' self.language = international.getLanguage() PackageInfoHandler.__init__(self, self.statusCallback, blocking=False, neededTag='ALL_TAGS', neededFlag=self.ImageVersion) self.directory = resolveFilename(SCOPE_METADIR) self.hardware_info = HardwareInfo() self.list = List([]) self.NotifierCallback = None self.Console = Console() self.UpdateConsole = Console() self.cmdList = [] self.unwanted_extensions = ('-dbg', '-dev', '-doc', '-staticdev', '-src') self.ipkg = IpkgComponent() self.ipkg.addCallback(self.ipkgCallback)
profile("InternationalLocalization") from Components.International import international config.osd = ConfigSubsection() if getMachineBrand() == "Atto.TV": defaultLocale = "pt_BR" elif getMachineBrand() == "Zgemma": defaultLocale = "en_US" elif getMachineBrand() == "Beyonwiz": defaultLocale = "en_AU" else: defaultLocale = "de_DE" config.misc.locale = ConfigText(default=defaultLocale) config.misc.language = ConfigText( default=international.getLanguage(defaultLocale)) config.misc.country = ConfigText( default=international.getCountry(defaultLocale)) config.osd.language = ConfigText(default=defaultLocale) config.osd.language.addNotifier(localeNotifier) # TODO # config.misc.locale.addNotifier(localeNotifier) # These entries should be moved back to UsageConfig.py when it is safe to bring UsageConfig init to this location in StartEnigma.py. # config.crash = ConfigSubsection() config.crash.debugActionMaps = ConfigYesNo(default=False) config.crash.debugKeyboards = ConfigYesNo(default=False) config.crash.debugOpkg = ConfigYesNo(default=False) config.crash.debugRemoteControls = ConfigYesNo(default=False) config.crash.debugScreens = ConfigYesNo(default=False)