【问题标题】:How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?如何使用 TagLib-Sharp 编写自定义 (PRIV) ID3 帧?
【发布时间】:2012-01-09 18:57:26
【问题描述】:

具体来说,我想编写 Windows Media Player 帧,例如WM/MediaClassPrimaryIDWM/MediaClassSecondaryIDWM/WMCollectionGroupID 帧。

我正在使用 PowerShell,但 C# 也不错。

【问题讨论】:

    标签: taglib-sharp


    【解决方案1】:

    我有点生疏了,但以下内容应该大部分是正确的。我记得这些标签是 UTF-16,但您可能想要获取现有标签并尝试使用 Unicode 编码器对其值进行解码以确定。

    // 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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      • 2015-03-29
      相关资源
      最近更新 更多