我需要在我的 IEnumerable 集合中播放歌曲,但是这种方法存在很多问题。如果我使用计时器检查 MediaState,它可能会起作用,但是当我从该页面导航时,课程将被取消并且音乐将停止。我想这样做的原因是能够播放不同专辑中的歌曲:
我的代码:
private SongCollection mySongCollection;
IEnumerable<Song> ultimateCollection;
mySongCollection = library.Albums[index].Songs;
ultimateCollection = mySongCollection.Concat(library.Albums[1].Songs);
foreach (Song a in ultimateCollection)
{
while (MediaPlayer.State == MediaState.Playing || MediaPlayer.State == MediaState.Paused)
{
//while MediaState still playing, dont play next song
}
MediaPlayer.Play(a);
}