public static string getSubtitle(string songName, int songTime) { string subtitleToShow = ""; songName = songName.ToLower(); if (subtitles == null) { Subtitles.getSubtitlesFromFile(Subtitles.SubtitlesPath); } if (subtitles != null && subtitles.ContainsKey(songName)) { Dictionary <int, string> songSubtitles = subtitles[songName]; int maximumSeconds = -1; foreach (KeyValuePair <int, string> subtitleAssociation in songSubtitles) { if (subtitleAssociation.Key > maximumSeconds && subtitleAssociation.Key <= songTime / 1000) { subtitleToShow = subtitleAssociation.Value; maximumSeconds = subtitleAssociation.Key; } } } else if (without != songName) { without = songName; Tools.log("Son sans sous titre : " + songName); } return(subtitleToShow); }
private void updateSubtitles() { string subtitle = ""; if (currentSoundIndex < playlist.Count) { KeyValuePair <string, ISound> currentPair = playlist.ElementAt(currentSoundIndex); string fileName = Path.GetFileName(FullPrefix + currentPair.Key + ".wav"); subtitle = Subtitles.getSubtitle(fileName, (int)currentPair.Value.PlayPosition); } if (subtitle != "") { GTA.UI.ShowSubtitle(subtitle); } }