小程序:LRC歌词展开

来源:互联网 发布:淘宝网店货物拍照 编辑:程序博客网 时间:2024/04/28 12:28

  LRC大家都知道吧(不知道?就是那个带时间标签的文本歌词格式嘛~),很好用的东东~所以最近很多MP3Player也开始支持它了。笔者手上就有一个联想F520的MP3支持,不过有点小麻烦,这个MP3只支持一行一个时间标签,但是笔者手头上的LRC一行都有好些时间标签,像这样,MP3就会把后面的时间标签全部显示出来(晕~)
  看来只能修改修改了~既然我们没办法修改MP3的固件,那就在LRC上动手脚吧~把他展开为每行一个时间标签不就得了~说干就干!
  不过我懒得再作界面,所以直接从命令行参数中获取,此外这个纠错机制不是很完善(毕竟才一个过程),大家也可以帮忙修改~
  代码如下:
Sub Main()
    Dim sCommand() As String
    Dim bTmp       As Byte
    Dim sTmp       As String
    Dim cFile      As Collection
    Dim iNum       As Integer
    Dim sTmp2      As String
    Dim i          As Integer
    Dim j          As Integer
    Dim sTmp3      As String
    Dim bIsAdd     As Boolean
    Set cFile = New Collection
    sCommand = Split(Command, "*") '用*作分隔符,很简单,文件名不能带*,用?也可以
    Open sCommand(0) For Input As #1
    Do Until EOF(1)
        Input #1, sTmp
        iNum = 0
        Do While ((Mid(sTmp, iNum * 9 + 1, 1) = "[") And (Mid(sTmp, (iNum + 1) * 9, 1) = "]"))
            iNum = iNum + 1
        Loop
        sTmp2 = Right(sTmp, Len(sTmp) - 9 * iNum)
        For i = 0 To iNum - 1
            sTmp3 = Mid(sTmp, i * 9 + 2, 7)
            If cFile.Count = 0 Then
                cFile.Add "[" & sTmp3 & "]" & sTmp2
            Else
                bIsAdd = False
                For j = 1 To cFile.Count
                    If Mid(cFile(j), 2, 7) > Mid(sTmp, i * 9 + 2, 7) Then
                        cFile.Add "[" & sTmp3 & "]" & sTmp2, , j
                        bIsAdd = True
                        Exit For
                    End If
                Next j
                If Not bIsAdd Then cFile.Add "[" & sTmp3 & "]" & sTmp2
            End If
        Next
i
    Loop
    Close #1
    Open sCommand(1) For Output As #1
    For i = 1 To cFile.Count
        Print #1, cFile(i)
    Next i
    Close #1
End Sub

  大家应该还能看的懂吧~这个经过试验还是不错的~

最终通过环境:VB6+Win2000

原创粉丝点击