public static Lyrics LoadFromStr(string raw) { var res = new Lyrics(); string[] lysList = raw.Split(new char[] { '\n' }); var lrcRegex = new Regex("\\[(\\d+):(\\d+\\.\\d+)\\]"); foreach (string t in lysList) { Match j = lrcRegex.Match(t); string lyric = ""; List<int> times = new List<int>(); int index = -1; while (j.Success) { string minutes = j.Groups[1].Value; string seconds = j.Groups[2].Value; int time = (int)((double.Parse(minutes) * 60.0 + double.Parse(seconds)) * 1000.0); times.Add(time); index = j.Index + j.Groups[0].Value.Length; j = j.NextMatch(); } if (index != -1 && index != t.Length) { lyric = t.Substring(index); } foreach (int time2 in times) { res.AddLyrics(time2, lyric); } } return res; }
public void SetUnSyncLyrics(Lyrics lyrics) { if (lyrics == null) { return; } ID3v23UnsynchedLyricsFrame lyricsFrame = new ID3v23UnsynchedLyricsFrame(TextEncodingTypes.Unicode); string str = ""; List<LyricsUnit> lyList = lyrics.GetSortedLyrics(); for (int i = 0; i < lyList.Count; i++) { str = str + lyList[i].Lyrics + "\n"; } lyricsFrame.UnsynchedLyrics = str; id3v2tag.Frames.Add(lyricsFrame); }
public void SetLyrics(Lyrics lyrics) { if (lyrics == null) { return; } ID3v23SynchronizedLyricsFrame lyricsFrame = new ID3v23SynchronizedLyricsFrame(TextEncodingTypes.Unicode); List<LyricsUnit> lyList = lyrics.GetLyris(); foreach (LyricsUnit t in lyList) { lyricsFrame.SynchronizedLyrics.Add(t.Lyrics, t.TimeStamp); } id3v2tag.Frames.Add(lyricsFrame); }