我需要在我的 Metro 应用程序中为 Windows 8 设置 mediaElement 控件的源!
这是我的代码:
string requestUrl = "ms-appx://ArcadiaDJ/Musique/test.mp3");
mediaElement_SoundEffect.Source = new Uri(requestUrl);
mediaElement_SoundEffect.play();
我可以设置源,但 mediaElement 不能在播放时工作.. 没有音乐
我找到了这个解决方案,但我需要在动态加载页面上设置源
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.SuggestedStartLocation =Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
openPicker.FileTypeFilter.Add(".mp3");
openPicker.FileTypeFilter.Add(".wav");
file = await openPicker.PickSingleFileAsync();
mediaControl.SetSource(stream, file.ContentType);
谢谢