【发布时间】:2013-05-13 20:00:17
【问题描述】:
我有一个用 c# 编写的 Windows Metro 应用程序。
这是我用来从本地音乐库中选择文件的代码:
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
}
上面说StorageFile不能转换成System.Uri用来改变MediaElement的来源。如何使我的文件成为 uri 链接?似乎Uri("...") 只接受文件位置的String。
【问题讨论】:
标签: c# windows-8 windows-runtime storagefile