I have a Windows Metro app written in c#.
Here is the code I am using to pick a file from a local music library:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
openPicker.FileTypeFilter.Add(".mp3");
openPicker.FileTypeFilter.Add(".wav");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
myMediaElement.Source = file; //error here
}
else
{
//error here
}
It says that StorageFile
cannot be converted to the System.Uri
used to change the source of MediaElement. How do I make my file became a uri link? It seems that Uri("...")
only accepts String
of where the file location is.