I am trying to load Thumbnails for a list of (Video, Audio and Image files), but my WinRT app keeps hanging, i am using the IValueConverter
Below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media.Imaging;
namespace App1.Common
{
public class ContentPathConverter : IValueConverter
{
private async Task<object> x(object value)
{
string s = value as string;
try
{
Uri uri = new Uri(s, UriKind.RelativeOrAbsolute);
var mediaFile = await StorageFile.GetFileFromPathAsync(s);
var thumbnail = await mediaFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView);
BitmapImage img = new BitmapImage();
img.SetSource(thumbnail);
return img;
}
catch
{
return null;
}
}
public object Convert(object value, Type targetType, object parameter, string language)
{
return x(value).Result;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
it Keeps hanging every time at this line:
var thumbnail = await mediaFile.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView);
How can i solve this?
thanks.