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