gpt4 book ai didi

file - 来自 ByteArray/Stream 的 TagLib-sharp 文件

转载 作者:行者123 更新时间:2023-12-01 06:19:21 24 4
gpt4 key购买 nike

是否可以使用 TagLib# 编辑代表 Mp3 文件的 ByteArray 的标签?

目前我需要这样做:

System.IO.File.WriteAllBytes(path + file + ".mp3", byt);
TagLib.File f = TagLib.File.Create(path + song + ".mp3");

是否可以避免这种情况并直接从 ByteArray 创建 TagLib.File?

最佳答案

试试这个:

var file = TagLib.File.Create(new FileBytesAbstraction(<file name>, <file bytes>));

其中 FileBytesAbstraction 是:
public class FileBytesAbstraction : TagLib.File.IFileAbstraction
{
public FileBytesAbstraction(string name, byte[] bytes)
{
Name = name;

var stream = new MemoryStream(bytes);
ReadStream = stream;
WriteStream = stream;
}

public void CloseStream(Stream stream)
{
stream.Dispose();
}

public string Name { get; private set; }

public Stream ReadStream { get; private set; }

public Stream WriteStream { get; private set; }
}

关于file - 来自 ByteArray/Stream 的 TagLib-sharp 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14959320/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com