0
我需要从mp3文件中获取缩略图。我实现了这一点,但它从来没有捕捉到缩略图。我检查了使用Windows Media Player和xbox音乐(在电话上)打开它们的图像的存在,但我无法在我的应用程序中检索它们。请帮助从c#xaml中获取mp3文件的缩略图,用于windows phone 8.1
async private void ThumbnailFetcher(StorageFile file)
{
if (file != null)
{
const ThumbnailMode thumbnailMode = ThumbnailMode.MusicView;
const uint size = 100;
using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(thumbnailMode, size))
{
if (thumbnail != null && thumbnail.Type == ThumbnailType.Image)
{
this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
BitmapImage thumbnailImage = new BitmapImage();//image used for display
thumbnailImage.SetSource(thumbnail);
CurrentAlbumArt.Source = thumbnailImage;
Debug.WriteLine("true");
});
}
else
{
Debug.WriteLine("False");
}
}
}
}
P.s它总是假。
似乎有在Windows Phone 8.1中的错误,我找遍了所有的夜晚,我可以实现的唯一方法是这样的
var fileStream = await file.OpenStreamForReadAsync();
var TagFile = File.Create(new StreamFileAbstraction(file.Name, fileStream, fileStream));
// Load you image data in MemoryStream
var tags = TagFile.GetTag(TagTypes.Id3v2);
IPicture pic = TagFile.Tag.Pictures[0];
MemoryStream ms = new MemoryStream(pic.Data.Data);
ms.Seek(0, SeekOrigin.Begin);
bitmap.SetSource(ms.AsRandomAccessStream());
AlbumArt.Source = bitmap;
,但它并没有太多工作..
它不工作,我读了关于Windows Phone 8.1的一个bug ...我完全卡住了..看我的编辑2 – BADWOLF
它在8.1.1对我来说很好工作 – iTR
真?你有没有试过这个代码?对我来说,它为每首歌曲提供了无尽的乐趣。我能做什么? – BADWOLF