它给了我一个找不到文件的异常?在资产内部我有“beep.wav”但不工作。
visual studio 2012\Projects\Myproject\Myproject\Assets
private async void beep()
{
MediaElement snd = new MediaElement();
StorageFolder folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
StorageFile file = await folder.GetFileAsync("beep.wav");
var stream = await file.OpenAsync(FileAccessMode.Read);
snd.SetSource(stream, file.ContentType);
snd.Play();
}
上面的代码确实有效,我只需要将它手动添加到项目中......