开发者

How to write id3v2 Album Artist using taglib with VB.Net

I can't figure out how to make taglib save certain tags that use arrays. For example when I save the album i can just type ID31.Album = txtalubm1.开发者_如何学JAVAtext. But if I want to save albumartist since its an array I cant seem to do it the same way.

Anyone know how to do this?


tagFile.Tag.AlbumArtists = New String() {"Album Artist"}


Brilliant!

The final step in my VB2010 Express mp3 metadata amendment program.

It now works like this: -

Store the mp3 files in a folder with the album name under a folder with the artists name.

Rename the files to have the track number in the first two characters, followed by a space and then the title.

Create a new project with a textbox called txtFolder and a button called cmdOK.

Add taglib-sharp.dll as a reference.

Run the project.

Enter the album's folder string as text in the textbox and click OK.

This code will amend the metadata.

Private Sub cmdOK_Click() Handles cmdOK.Click
    '
    'check folder exists
    '
    If Not My.Computer.FileSystem.DirectoryExists(txtFolder.Text) Then
        MsgBox("Folder does not exist", vbExclamation)
        Exit Sub
    End If
    '
    'set up details from folder name
    '
    LastSlash = InStrRev(txtFolder.Text, "\")
    AlbumStore = Microsoft.VisualBasic.Mid(txtFolder.Text, LastSlash + 1)
    FolderStore = Microsoft.VisualBasic.Left(txtFolder.Text, LastSlash - 1)
    LastSlash = InStrRev(FolderStore, "\")
    ArtistStore = Microsoft.VisualBasic.Mid(FolderStore, LastSlash + 1)
    '
    'get each file in folder
    '
    For Each foundFile As String In My.Computer.FileSystem.GetFiles(txtFolder.Text)
        If LCase(Microsoft.VisualBasic.Right(foundFile, 4)) = ".mp3" Then
            '
            'set up details from file name
            '
            LastSlash = InStrRev(foundFile, "\")
            FileStore = Microsoft.VisualBasic.Mid(foundFile, LastSlash + 1)
            FileStore = Microsoft.VisualBasic.Left(FileStore, Len(FileStore) - 4)
            TrackStore = Microsoft.VisualBasic.Left(FileStore, 2)
            TitleStore = Microsoft.VisualBasic.Mid(FileStore, 4)
            '
            'set up and modify metadata
            '
            Dim mp3 As TagLib.File = TagLib.File.Create(foundFile)
            mp3.Tag.Track = Val(TrackStore)
            mp3.Tag.Title = TitleStore
            mp3.Tag.Album = AlbumStore
            mp3.Tag.Performers = New String() {ArtistStore}
            mp3.Tag.AlbumArtists = New String() {ArtistStore}
            mp3.Save()
            mp3.Dispose()
        End If
    Next

    End

End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜