void CreatePlaybackList(IEnumerable<Track> songs)
{
// Make a new list and enable looping
playbackList = new MediaPlaybackList();
playbackList.AutoRepeatEnabled = true;
// Add playback items to the list
foreach (var song in songs)
{
var source = MediaSource.CreateFromUri(GetMusicFile(song.Id));
source.CustomProperties[TrackIdKey] = song.Id;
source.CustomProperties[TitleKey] = song.Title;
source.CustomProperties[ArtistKey] = song.User.Username;
source.CustomProperties[AlbumArtKey] = song.ArtworkUrl;
playbackList.Items.Add(new MediaPlaybackItem(source));
}
// Don't auto start
BackgroundMediaPlayer.Current.AutoPlay = true;
// Assign the list to the player
BackgroundMediaPlayer.Current.Source = playbackList;
// Add handler for future playlist item changes
playbackList.CurrentItemChanged += PlaybackList_CurrentItemChanged;
}
#endregion