I'm trying to get the thumbnail of the StorageFile located inside the application package (LocalFolder) of the app. The storage file is a media file which can be image(jpg or png) or a video (mp4 or wmv). Now when i try to get the thumbnail using GetThumbnailAsync(ThumbnailMode) method of the StorageFile class i get a
System.Exception : The component cannot be found.
error, while the same thing works fine if the file is image or a video which is not inside the app package. Here is the codebehind i'm using
StorageFile file;
private async void BtnGetVideo_Click(object sender, RoutedEventArgs e)
{
StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets\\TestImgs");
file = await folder.GetFileAsync("SMTest.mp4");
}
private async void BtnGetThumb_Click(object sender, RoutedEventArgs e)
{
if (file != null)
{
BitmapImage image = new BitmapImage();
image.SetSource(await file.GetThumbnailAsync(ThumbnailMode.VideosView));
ImagePreview.Source = image;
}
}
and here is the xaml for it
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="BtnGetVideo" Content="Get a Local Video" Click="BtnGetVideo_Click"/>
<Button x:Name="BtnGetThumb" Content="Get Thumbnails" Click="BtnGetThumb_Click"/>
<Image x:Name="ImagePreview" Height="200"/>
</StackPanel>