Reading Image and Video from device in windows phone 8.1:
MainPage.Xaml
<Button x:Name="btnPhotos" HorizontalAlignment="Left" Margin="2,256,0,0" VerticalAlignment="Top" FontFamily="Arial" Width="388" Height="96" Click="btnPhotos_Click">
<TextBlock x:Name="textBlock" Text="Photos" FontSize="28" Foreground="#FF7A7070" Width="210" Height="42" />
</Button>
<Button x:Name="btnVideo" HorizontalAlignment="Left" Height="99" Margin="3,366,0,0" VerticalAlignment="Top" FontFamily="Arial" Width="387" Click="btnVideo_Click">
<TextBlock Name="textVideo" Text="Video" FontSize="28" Margin="10,0,23,0" Foreground="#FF7A7070" Width="210" Height="42">
</TextBlock>
</Button> <b>MainPage.Xaml.csprivate async void btnPhotos_Click(object sender, RoutedEventArgs e)
{
photosProgressBar.Visibility = Visibility.Visible;
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
openPicker.PickMultipleFilesAndContinue();
}
private async void btnVideo_Click(object sender, RoutedEventArgs e)
{
videoProgressBar.Visibility = Visibility.Visible;
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
openPicker.FileTypeFilter.Add(".mp4");
openPicker.PickMultipleFilesAndContinue();
}
public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
{
IReadOnlyList < StorageFile > files = args.Files;
if (files.Count > 0)
{
foreach(var item in files)
{
//Do your work
}
}
}
< b >App.Xaml.csprotected override void OnActivated(IActivatedEventArgs args)
{
// Sync osync = new Sync();
var root = Window.Current.Content as Frame;
var sync = root.Content as Sync;
if (sync != null && args is FileOpenPickerContinuationEventArgs)
{
sync.ContinueFileOpenPicker(args as FileOpenPickerContinuationEventArgs);
}
}