1
我在設備上創建了歌曲列表。如何從listView開始播放歌曲?
對於每個項目,在我的ListView中顯示藝術家姓名和歌曲名稱。我希望當選擇一首歌曲開始播放時,我將如何去?
StorageFolder musicLibrary = KnownFolders.MusicLibrary;
IReadOnlyList<StorageFile> musica = await musicLibrary.GetFilesAsync();
if (musica != null)
{
List<Testo> song = new List<Testo>();
{
foreach (StorageFile storage in musica)
{
MusicProperties musicProp = await storage.Properties.GetMusicPropertiesAsync();
song.Add(new Testo
{
NomeArtista = musicProp.Artist,
NomeCanzone = musicProp.Title,
Anno = (int)musicProp.Year,
});
}
}
}
private async void TestiCanzone_ItemClick(object sender, ItemClickEventArgs e)
{
Testo NuovoTesto = e.ClickedItem as Testo;
}
我還創建了一個MediaElement的
<MediaElement x:Name="AudioPlay" Source="" AutoPlay="True"/>
你使用MVVM和綁定嗎? – RenDishen
在XAML中使用綁定 – SMM
您的意思是每當選擇一首歌曲時,它應該會自動播放該歌曲? – Kulasangar