private void GetWpAlbums(object state)
{
var wmp = new WindowsMediaPlayer();
var collection = wmp.mediaCollection;
this.authorIndex = collection.getMediaAtom("Author");
this.albumArtistIndex = collection.getMediaAtom("WM/AlbumArtist");
this.albumIndex = collection.getMediaAtom("Album");
IWMPPlaylist allMedia = collection.getAll();
List<ServiceAgnosticAlbum> albums = new List<ServiceAgnosticAlbum>();
for (int i = 0; i < allMedia.count; i++)
{
var currentMedia = allMedia.get_Item(i);
var artistName = GetArtist(currentMedia);
var albumName = GetAlbum(currentMedia);
if (!string.IsNullOrEmpty(artistName) &&
!string.IsNullOrEmpty(albumName) &&
!albums.Any(a => a.AlbumName == albumName && a.ArtistName == artistName))
{
albums.Add(new ServiceAgnosticAlbum(albumName, artistName));
}
}
App.AlbumsToImport = albums;
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ThreadStart(() => this.Navigate(new CollectionImporter())));
}