LRC是英文lyric(歌词)的缩写,被用做歌词文件的扩展名.以lrc为扩展名的歌词文件可以在各类数码播放器中同步显示.LRC 歌词是一种包含着“*:*”形式的“标签(tag)”的基于纯文本的歌词专用格式.
1.标识标签(ID-tags)
[ar:艺人名]
[ti:曲名]
[al:专辑名]
[by:编者(指编辑LRC歌词的人)]
[offset:时间补偿值] 其单位是毫秒,正值表示整体提前,负值相反.这是用于总体调整显示快慢的.
[ti:山丘]
[ar:李宗盛]
[offset:0]
2.时间标签(Time-tag)
[mm:ss:fff]具体歌词内容
[00:19.59] 想说却还没说的 还很多
[00:28.97] 攒着是因为想写成歌
[00:33.91] 让人轻轻地唱着 淡淡地记着
Public Class LyricClass Structure LyricStructre ‘歌词结构类型 Dim Count As Integer Dim LyricTime As List(Of Integer) ‘每行歌词的时间序列 Dim LyricString As List(Of String) ‘每行歌词的字符串序列 End Structure Structure InformationStructre ‘歌词信息结构类型 Dim Author As String ‘作者名[ar] Dim Title As String ‘歌曲名[ti] Dim Album As String ‘专辑名[al] Dim Editor As String ‘编者[by] Dim Offset As Integer ‘时间补偿值[offset] End Structure Public LyricData As New LyricStructre With {.LyricTime = New List(Of Integer), .LyricString = New List(Of String)} Public LyricInf As New InformationStructre Public isLoadFail As Boolean = False ‘是否加载失败 Public Sub New(ByVal FileName As String) LoadLyrics(FileName) End Sub Public Sub LoadLyrics(ByVal FileName As String) Dim str As String LyricData.Count = 0 LyricData.LyricTime.Clear() LyricData.LyricString.Clear() If My.Computer.FileSystem.FileExists(FileName) = True Then str = My.Computer.FileSystem.ReadAllText(FileName, System.Text.Encoding.Default) Dim tempString As String For Each SubString As String In Split(str, vbCrLf) tempString = Mid(SubString, 2, 2) If IsNumeric(tempString) = True Then LyricData.count += 1 LyricData.LyricTime.Add(Mid(SubString, 2, 2) * 60 * 100 + Mid(SubString, 5, 2) * 100 + Mid(SubString, 8, 2)) LyricData.LyricString.Add(Mid(SubString, SubString.IndexOf("]") + 2)) ElseIf tempString = "ar" Then LyricInf.Author = Split(Split(SubString, ":")(1), "]")(0) ElseIf tempString = "ti" Then LyricInf.Title = Split(Split(SubString, ":")(1), "]")(0) ElseIf tempString = "al" Then LyricInf.Album = Split(Split(SubString, ":")(1), "]")(0) ElseIf tempString = "by" Then LyricInf.Editor = Split(Split(SubString, ":")(1), "]")(0) ElseIf tempString = "of" Then LyricInf.Offset = Split(Split(SubString, ":")(1), "]")(0) End If Next Else isLoadFail = True ‘加载失败 End If End Sub End Class
时间: 2024-10-11 22:49:49