问题
Specifically, I'd like to write the Windows Media Player frames, such as theWM/MediaClassPrimaryID
, WM/MediaClassSecondaryID
and WM/WMCollectionGroupID
frames.
I'm using PowerShell, but C# would be good too.
回答1:
I'm a bit rusty, but the following should be mostly correct. I remember these tags being UTF-16 but you'll probably want to get an existing tag and try decoding its value with the Unicode encoder to be sure.
// Get or create the ID3v2 tag.
TagLib.Id3v2.Tag id3v2_tag = file.GetTag(TagLib.TagTypes.Id3v2, true);
if(id3v2_tag != null) {
// Get the private frame, create if necessary.
PrivateFrame frame = PrivateFrame.Get(id3v2_tag, "WM/MediaClassPrimaryID", true);
// Set the frame data to your value. I am 90% sure that these are encoded with UTF-16.
frame.PrivateData = System.Text.Encoding.Unicode.GetBytes(value);
}
来源:https://stackoverflow.com/questions/8793640/how-do-i-use-taglib-sharp-to-write-custom-priv-id3-frames