如何播放音乐库中的歌曲?我试过这个:
private void click_AlarmSet(object sender, RoutedEventArgs e)
{
play();
}
async private void play()
{
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.SuggestedStartLocation =Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
openPicker.FileTypeFilter.Add("toxic.mp3");
var file = await openPicker.PickSingleFileAsync();
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
sound.SetSource(stream, file.ContentType);
sound.Play();
}
这sound
是我的媒体元素,“toxic.mp3”是我想播放的 mp3 文件,但 mp3 没有播放。