コード例 #1
0
ファイル: MyLyric.cs プロジェクト: ewsq/wpf-music-player
        private void GetLyricContentAndTime(string tempStr)
        {
            //以中括号分割
            string[] lineStr = tempStr.Split(']');
            int      indexM  = lineStr.Length;

            for (int i = 0; i < indexM - 1; i++)
            {
                string time = lineStr[i].Substring(1);
                if (time.Contains('.'))
                {
                    time = time.Replace('.', ':');
                }
                if (time[1] >= '0' && time[1] <= '9')
                {
                    LyricTimeLines.Add(time);
                    if (lineStr[indexM - 1].Trim() == "")
                    {
                        LyricTextLines.Add("Music ~ ~ ~");
                    }
                    else
                    {
                        LyricTextLines.Add(lineStr[indexM - 1]);
                    }
                }
            }
        }
コード例 #2
0
ファイル: MyLyric.cs プロジェクト: ewsq/wpf-music-player
 /// <summary>
 /// 方法:解析lrc歌词文件。该方法在使用歌词类的空构造函数时必须被调用一次,否则无法得到解析的文件。
 /// </summary>
 /// <param name="lyricPath">歌词文件路径</param>
 public void AnalyzeLyricFile(string fileString)
 {
     //进行歌词的解析
     StartAnalyzeLyric(fileString);
     //接下来对歌词进行按时间的排序
     //不知道效率如何,但是毕竟是自己想的,就试试吧,,
     //拼字
     for (int i = 0; i < LyricTimeLines.Count; i++)
     {
         LyricTimeLines[i] += '\n' + LyricTextLines[i];
     }
     //排序
     LyricTimeLines.Sort();
     //拆字
     for (int i = 0; i < LyricTimeLines.Count; i++)
     {
         string[] splitStr =
             LyricTimeLines[i].Split('\n');
         LyricTimeLines[i] = splitStr[0];
         ConvertTimeToDoubleValue(splitStr[0]);
         LyricTextLines[i] = splitStr[1];
     }
 }