gpt4 book ai didi

c# - 如何在 Win8 C# 应用程序中设置专辑插图?

转载 作者:太空宇宙 更新时间:2023-11-03 16:14:58 24 4
gpt4 key购买 nike

我希望能够拍摄现有照片并将其设置为专辑插图。

我可以使用 GetThumbnailAsync 给我一个缩略图,并使用 GetOutputStream 获取缩略图输出流。不幸的是,它不可写。

如何在 Win8 C# 应用程序中为项目设置专辑封面(或任何缩略图)?

当前(非工作)代码。当 outStream 因拒绝访问错误而刷新时它会死掉

    FileOpenPicker fileopenpicker = new FileOpenPicker();

fileopenpicker.FileTypeFilter.Add(".jpg");
fileopenpicker.FileTypeFilter.Add(".png");

fileopenpicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;// | PickerLocationId.DocumentsLibrary | PickerLocationId.PicturesLibrary | PickerLocationId.MusicLibrary;

var singlefileoperation = await fileopenpicker.PickSingleFileAsync();
var read = await singlefileoperation.OpenAsync(FileAccessMode.Read);

StorageFile replay = currentlyPlaying;
TimeSpan pos = ME.Position;
ME.Stop();

//curren
StorageItemThumbnail storageItemThumbnail = await currentlyPlaying.GetThumbnailAsync(ThumbnailMode.SingleItem);




IOutputStream inputStreamAt = storageItemThumbnail.GetOutputStreamAt(0);
Stream outStream = inputStreamAt.AsStreamForWrite();

var inStreamAt = read.GetInputStreamAt(0);
var inStream = inStreamAt.AsStreamForRead();
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
outStream.Dispose();
inStream.Dispose();
inStreamAt.Dispose();

最佳答案

TagLib Sharp应该对您正在寻找的内容有所帮助。

TagLib.File tagFile = TagLib.File.Create(c:/yourpath/yoursong.mp3);
IPicture newArt = new Picture(c:/yourimagepath/youralbumart.jpg);
tagFile.Tag.Pictures = new IPicture[1] {newArt};
tagFile.Save();

Code Source

编辑:更新了 TagLib Sharp 库的链接

关于c# - 如何在 Win8 C# 应用程序中设置专辑插图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16029437/

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