private void parseLyrics(string lyrics) { lyrics_ = new List <LyricsText>(); lyrics = lyrics.Replace("\r\n", "\n").Replace("\r", "\n"); int position = lyrics.IndexOf("\n"); while (position != -1) { LyricsText textObject = new LyricsText(); string temp = lyrics.Substring(0, position); lyrics = lyrics.Remove(0, position + 1); int timepos = temp.IndexOf("["); int timepos2 = temp.IndexOf("]"); if (timepos != -1 && timepos2 != -1) { int timeInt = 0; string time = temp.Substring(timepos + 1, timepos2 - timepos - 1); int doublePointPos = time.IndexOf(":"); timeInt += Convert.ToInt32(time.Substring(0, doublePointPos)) * 60000; time = time.Remove(0, doublePointPos + 1); doublePointPos = time.IndexOf("."); if (doublePointPos != -1) { timeInt += Convert.ToInt32(time.Substring(0, doublePointPos)) * 1000; time = time.Remove(0, doublePointPos + 1); } timeInt += Convert.ToInt32(time); textObject.text = temp.Remove(0, timepos2 + 1); textObject.time = timeInt; synchronized_ = true; } else { synchronized_ = false; textObject.text = temp; textObject.time = 0; } if (textObject.text != "" && textObject.text != null) { lyrics_.Add(textObject); } position = lyrics.IndexOf("\n"); } }
public override void songChanged(string artist, string album, string title, float rating, string artwork, int duration, int position, string lyrics) { lyrics_ = null; lyricsPosition_ = 0; if (lyrics != null && lyrics.Length != 0) { parseLyrics(lyrics); } else { lyrics_ = new List <LyricsText>(); LyricsText textObject = new LyricsText(); textObject.text = "No lyrics found"; textObject.time = 0; lyrics_.Add(textObject); } }