示例#1
0
		internal Song(Album album, Artist artist, Genre genre, MusicProperties musicProperties)
		{
            this.album = album;
            this.artist = artist;
            this.genre = genre;
            this.musicProperties = musicProperties;
		}
示例#2
0
        private void PlatformLoad(Action<int> progressCallback)
        {
            var songList = new List<Song>();
            var albumList = new List<Album>();

            foreach (var collection in MPMediaQuery.AlbumsQuery.Collections)
            {
                var nsAlbumArtist = collection.RepresentativeItem.ValueForProperty(MPMediaItem.AlbumArtistProperty);
                var nsAlbumName = collection.RepresentativeItem.ValueForProperty(MPMediaItem.AlbumTitleProperty);
                var nsAlbumGenre = collection.RepresentativeItem.ValueForProperty(MPMediaItem.GenreProperty);
                string albumArtist = nsAlbumArtist == null ? "Unknown Artist" : nsAlbumArtist.ToString();
                string albumName = nsAlbumName == null ? "Unknown Album" : nsAlbumName.ToString();
                string albumGenre = nsAlbumGenre == null ? "Unknown Genre" : nsAlbumGenre.ToString();
                MPMediaItemArtwork thumbnail = collection.RepresentativeItem.ValueForProperty(MPMediaItem.ArtworkProperty) as MPMediaItemArtwork;

                var albumSongs = new List<Song>((int)collection.Count);
                var album = new Album(new SongCollection(albumSongs), albumName, new Artist(albumArtist), new Genre(albumGenre), thumbnail);
                albumList.Add(album);

                foreach (var item in collection.Items)
                {
                    var nsArtist = item.ValueForProperty(MPMediaItem.ArtistProperty);
                    var nsTitle = item.ValueForProperty(MPMediaItem.TitleProperty);
                    var nsGenre = item.ValueForProperty(MPMediaItem.GenreProperty);
                    var assetUrl = item.ValueForProperty(MPMediaItem.AssetURLProperty) as NSUrl;

                    if (nsTitle == null || assetUrl == null) // The Asset URL check will exclude iTunes match items from the Media Library that are not downloaded, but show up in the music app
                        continue;

                    string artist = nsArtist == null ? "Unknown Artist" : nsArtist.ToString();
                    string title = nsTitle.ToString();
                    string genre = nsGenre == null ? "Unknown Genre" : nsGenre.ToString();
                    TimeSpan duration = TimeSpan.FromSeconds(((NSNumber)item.ValueForProperty(MPMediaItem.PlaybackDurationProperty)).FloatValue);

                    var song = new Song(album, new Artist(artist), new Genre(genre), title, duration, item, assetUrl);
                    albumSongs.Add(song);
                    songList.Add(song);
                }
            }

            albumCollection = new AlbumCollection(albumList);
            songCollection = new SongCollection(songList);

            /*_playLists = new PlaylistCollection();
					
			MPMediaQuery playlists = new MPMediaQuery();
			playlists.GroupingType = MPMediaGrouping.Playlist;
            for (int i = 0; i < playlists.Collections.Length; i++)
            {
                MPMediaItemCollection item = playlists.Collections[i];
                Playlist list = new Playlist();
                list.Name = playlists.Items[i].ValueForProperty(MPMediaPlaylistPropertyName).ToString();
                for (int k = 0; k < item.Items.Length; k++)
                {
                    TimeSpan time = TimeSpan.Parse(item.Items[k].ValueForProperty(MPMediaItem.PlaybackDurationProperty).ToString());
                    list.Duration += time;
                }
                _playLists.Add(list);
            }*/
        }
示例#3
0
 internal Song(Album album, Artist artist, Genre genre, string title, TimeSpan duration, MPMediaItem mediaItem, NSUrl assetUrl)
 {
     this.album = album;
     this.artist = artist;
     this.genre = genre;
     this.title = title;
     this.duration = duration;
     this.mediaItem = mediaItem;
     this.assetUrl = assetUrl;
 }
示例#4
0
 internal Song(Album album, Artist artist, Genre genre, string title, TimeSpan duration, object mediaItem, NSUrl assetUrl)
 #endif
 {
     this.album = album;
     this.artist = artist;
     this.genre = genre;
     this.title = title;
     this.duration = duration;
     #if !TVOS
     this.mediaItem = mediaItem;
     #endif
     this.assetUrl = assetUrl;
 }
        private void songsOfAlbum_Loaded(object sender, RoutedEventArgs e)
        {
            string _albumName = NavigationContext.QueryString["albumName"];

            MediaLibrary    medialib        = new MediaLibrary();
            AlbumCollection albumCollection = medialib.Albums;

            Microsoft.Xna.Framework.Media.Album album = albumCollection.Single(al => al.Name == _albumName);
            songCollection = album.Songs;


            songs.Clear();

            foreach (Song so in album.Songs)
            {
                songs.Add(so);
            }

            loadList.Begin();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                string _albumName = NavigationContext.QueryString["albumName"];

                MediaLibrary    medialib                  = new MediaLibrary();
                AlbumCollection albumCollection           = medialib.Albums;
                Microsoft.Xna.Framework.Media.Album album = albumCollection.Single(al => al.Name == _albumName);
                songCollection = album.Songs;



                if (album.HasArt)
                {
                    BitmapImage bmpImage = new BitmapImage();
                    bmpImage.SetSource(album.GetAlbumArt());
                    albumArt.Source = bmpImage;
                }


                albumName.Text   = album.Name;
                AlbumArtist.Text = album.Artist.Name;
                if (album.Duration.Days > 0)
                {
                    albumDuration.Text = string.Format("Duration: {0:D1}:{1:D2}:{2:D2}:{3:D2}", album.Duration.Days
                                                       , album.Duration.Hours, album.Duration.Minutes, album.Duration.Minutes);
                }
                else
                {
                    albumDuration.Text = string.Format("Duration: {0:D2}:{1:D2}:{2:D2}", album.Duration.Hours, album.Duration.Minutes, album.Duration.Minutes);
                }
                songsNumbers.Text = "Songs numbers: " + album.Songs.Count;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#7
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            ml = new MediaLibrary();
            String album_name = null;
            if (NavigationContext.QueryString.TryGetValue("Album", out album_name))
            {
                AlbumName.Text = album_name;
                foreach (Album a in ml.Albums)
                {
                    if (a.Name == album_name)
                    {
                        CurrentAlbum = a;
                        SongsList.ItemsSource = a.Songs;
                    }
                }
            }
            String song_name = null;
            if (NavigationContext.QueryString.TryGetValue("Song", out song_name))
            {
                foreach(Song s in CurrentAlbum.Songs)
                {
                    if (s.Name == song_name) currentSong = s;
                    changePlayButtonStatus();
                    changeSongName();
                    changeProgressBar();
                }
            }

            //MediaPlayer.MediaStateChanged += MediaPlayer_MediaStateChanged;
        }
示例#8
0
		internal Song(Album album, Artist artist, Genre genre, MusicProperties musicProperties)
			: this(album, artist, genre)
		{
			this.musicProperties = musicProperties;
		}
示例#9
0
 private void PlatformSetAlbum(Album album)
 {
     this.album = album;
 }
示例#10
0
        private void PlatformLoad(Action <int> progressCallback)
        {
            MPMediaQuery mediaQuery = new MPMediaQuery();
            var          value      = NSObject.FromObject(MPMediaType.Music);
            var          type       = MPMediaItem.MediaTypeProperty;
            var          predicate  = MPMediaPropertyPredicate.PredicateWithValue(value, type);

            mediaQuery.AddFilterPredicate(predicate);
            mediaQuery.GroupingType = MPMediaGrouping.Album;

            List <Song>  songList  = new List <Song>();
            List <Album> albumList = new List <Album>();

            for (int i = 0; i < mediaQuery.Collections.Length; i++)
            {
                MPMediaItemCollection itemCollection = mediaQuery.Collections[i];
                List <Song>           albumSongs     = new List <Song>((int)itemCollection.Count);

                var                nsAlbumArtist = itemCollection.RepresentativeItem.ValueForProperty(MPMediaItem.AlbumArtistProperty);
                var                nsAlbumName   = itemCollection.RepresentativeItem.ValueForProperty(MPMediaItem.AlbumTitleProperty);
                var                nsAlbumGenre  = itemCollection.RepresentativeItem.ValueForProperty(MPMediaItem.GenreProperty);
                string             albumArtist   = nsAlbumArtist == null ? "Unknown Artist" : nsAlbumArtist.ToString();
                string             albumName     = nsAlbumName == null ? "Unknown Album" : nsAlbumName.ToString();
                string             albumGenre    = nsAlbumGenre == null ? "Unknown Genre" : nsAlbumGenre.ToString();
                MPMediaItemArtwork thumbnail     = itemCollection.RepresentativeItem.ValueForProperty(MPMediaItem.ArtworkProperty) as MPMediaItemArtwork;

                var album = new Album(new SongCollection(albumSongs), albumName, new Artist(albumArtist), new Genre(albumGenre), thumbnail);
                albumList.Add(album);

                for (int j = 0; j < itemCollection.Count; j++)
                {
                    var nsArtist = itemCollection.Items[j].ValueForProperty(MPMediaItem.ArtistProperty);
                    var nsTitle  = itemCollection.Items[j].ValueForProperty(MPMediaItem.TitleProperty);
                    var nsGenre  = itemCollection.Items[j].ValueForProperty(MPMediaItem.GenreProperty);
                    var assetUrl = itemCollection.Items[j].ValueForProperty(MPMediaItem.AssetURLProperty) as NSUrl;

                    if (nsTitle == null || assetUrl == null) // The Asset URL check will exclude iTunes match items from the Media Library that are not downloaded, but show up in the music app
                    {
                        continue;
                    }

                    string   artist   = nsArtist == null ? "Unknown Artist" : nsArtist.ToString();
                    string   title    = nsTitle.ToString();
                    string   genre    = nsGenre == null ? "Unknown Genre" : nsGenre.ToString();
                    TimeSpan duration = TimeSpan.FromSeconds(((NSNumber)itemCollection.Items[j].ValueForProperty(MPMediaItem.PlaybackDurationProperty)).FloatValue);

                    var song = new Song(album, new Artist(artist), new Genre(genre), title, duration, itemCollection.Items[j], assetUrl);
                    albumSongs.Add(song);
                    songList.Add(song);
                }
            }

            albumCollection = new AlbumCollection(albumList);
            songCollection  = new SongCollection(songList);

            /*_playLists = new PlaylistCollection();
             *
             *          MPMediaQuery playlists = new MPMediaQuery();
             *          playlists.GroupingType = MPMediaGrouping.Playlist;
             * for (int i = 0; i < playlists.Collections.Length; i++)
             * {
             *  MPMediaItemCollection item = playlists.Collections[i];
             *  Playlist list = new Playlist();
             *  list.Name = playlists.Items[i].ValueForProperty(MPMediaPlaylistPropertyName).ToString();
             *  for (int k = 0; k < item.Items.Length; k++)
             *  {
             *      TimeSpan time = TimeSpan.Parse(item.Items[k].ValueForProperty(MPMediaItem.PlaybackDurationProperty).ToString());
             *      list.Duration += time;
             *  }
             *  _playLists.Add(list);
             * }*/
        }
示例#11
0
		internal Song(Album album, Artist artist, Genre genre)
        {
            this.album = album;
            this.artist = artist;
            this.genre = genre;
        }
示例#12
0
 internal Song(Album album, Artist artist, Genre genre, string title, TimeSpan duration, MPMediaItem mediaItem, NSUrl assetUrl)
示例#13
0
 internal Song(Album album, Artist artist, Genre genre, string title, TimeSpan duration, MPMediaItem mediaItem, NSUrl assetUrl)
示例#14
0
 internal Song(Album album, Artist artist, Genre genre)
 {
     this.album  = album;
     this.artist = artist;
     this.genre  = genre;
 }
示例#15
0
 private Song(Album album, Artist artist, Genre genre)
 {
     this.album = album;
     this.artist = artist;
     this.genre = genre;
 }
 /// <summary>
 /// Plays the album.
 /// </summary>
 /// <param name="album">The album.</param>
 public void PlayAlbum(Album album)
 {
     MediaPlayer.Play(album.Songs);
 }
示例#17
0
        private void PlatformLoad(Action<int> progressCallback)
        {
#if !WINDOWS_UAP
            Task.Run(async () =>
            {
                if (musicFolder == null)
                {
                    try
                    {
                        musicFolder = KnownFolders.MusicLibrary;
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine("Failed to access Music Library: " + e.Message);
                        albumCollection = new AlbumCollection(new List<Album>());
                        songCollection = new SongCollection(new List<Song>());
                        return;
                    }
                }
                    
            
                var files = new List<StorageFile>();
                await this.GetAllFiles(musicFolder, files);

                var songList = new List<Song>();
                var albumList = new List<Album>();

                var artists = new Dictionary<string, Artist>();
                var albums = new Dictionary<string, Album>();
                var genres = new Dictionary<string, Genre>();

                var cache = new Dictionary<string, MusicProperties>();

                // Read cache
                var cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.OpenIfExists);
                using (var stream = new BinaryReader(await cacheFile.OpenStreamForReadAsync()))
                    try
                    {
                        for (; stream.BaseStream.Position < stream.BaseStream.Length; )
                        {
                            var entry = MusicProperties.Deserialize(stream);
                            cache.Add(entry.Path, entry);
                        }
                    }
                    catch { }

                // Write cache
                cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.ReplaceExisting);
                using (var stream = new BinaryWriter(await cacheFile.OpenStreamForWriteAsync()))
                {
                    int prevProgress = 0;

                    for (int i = 0; i < files.Count; i++)
                    {
                        var file = files[i];
                        try
                        {
                            MusicProperties properties;
                            if (!(cache.TryGetValue(file.Path, out properties) && properties.TryMatch(file)))
                                properties = new MusicProperties(file);
                            properties.Serialize(stream);

                            if (string.IsNullOrWhiteSpace(properties.Title))
                                continue;

                            Artist artist;
                            if (!artists.TryGetValue(properties.Artist, out artist))
                            {
                                artist = new Artist(properties.Artist);
                                artists.Add(artist.Name, artist);
                            }

                            Artist albumArtist;
                            if (!artists.TryGetValue(properties.AlbumArtist, out albumArtist))
                            {
                                albumArtist = new Artist(properties.AlbumArtist);
                                artists.Add(albumArtist.Name, albumArtist);
                            }

                            Genre genre;
                            if (!genres.TryGetValue(properties.Genre, out genre))
                            {
                                genre = new Genre(properties.Genre);
                                genres.Add(genre.Name, genre);
                            }

                            Album album;
                            if (!albums.TryGetValue(properties.Album, out album))
                            {
                                var thumbnail = Task.Run(async () => await properties.File.GetThumbnailAsync(ThumbnailMode.MusicView, 300, ThumbnailOptions.ResizeThumbnail)).Result;
                                album = new Album(new SongCollection(), properties.Album, albumArtist, genre, thumbnail.Type == ThumbnailType.Image ? thumbnail : null);
                                albums.Add(album.Name, album);
                                albumList.Add(album);
                            }

                            var song = new Song(album, artist, genre, properties);
                            song.Album.Songs.Add(song);
                            songList.Add(song);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("MediaLibrary exception: " + e.Message);
                        }

                        int progress = 100 * i / files.Count;
                        if (progress > prevProgress)
                        {
                            prevProgress = progress;
                            if (progressCallback != null)
                                progressCallback.Invoke(progress);
                        }
                    }
                }

                if (progressCallback != null)
                    progressCallback.Invoke(100);

                albumCollection = new AlbumCollection(albumList);
                songCollection = new SongCollection(songList);
            }).Wait();
#endif
        }
示例#18
0
 private void PlatformSetAlbum(Album album)
 {
     this.album = album;
 }
示例#19
0
 internal Song(Album album, Artist artist, Genre genre, MusicProperties musicProperties)
     : this(album, artist, genre)
 {
     this.musicProperties = musicProperties;
 }
示例#20
0
 private Song(Album album, Artist artist, Genre genre)
 {
     this.album  = album;
     this.artist = artist;
     this.genre  = genre;
 }
 public void Add(Album album)
 {
     foreach (Song s in album.Songs)
         Add(s);
 }
示例#22
0
 private AlbumInfo createAlbumInfoFromAlbum(Album album)
 {
     return new AlbumInfo(album.Artist.Name, album.Name);
 }
 public void Insert(Album album, int index)
 {
     foreach (Song s in album.Songs)
         Insert(s, index++);
 }
示例#24
0
 public albumInfo(Album album)
 {
     this.name = album.Name;
 }
示例#25
0
        private void PlatformLoad(Action<int> progressCallback)
        {
            List<Song> songList = new List<Song>();
            List<Album> albumList = new List<Album>();

            using (var musicCursor = Context.ContentResolver.Query(MediaStore.Audio.Media.ExternalContentUri, null, null, null, null))
            {
                if (musicCursor != null)
                {
                    Dictionary<string, Artist> artists = new Dictionary<string, Artist>();
                    Dictionary<string, Album> albums = new Dictionary<string, Album>();
                    Dictionary<string, Genre> genres = new Dictionary<string, Genre>();

                    // Note: Grabbing album art using MediaStore.Audio.AlbumColumns.AlbumArt and
                    // MediaStore.Audio.AudioColumns.AlbumArt is broken
                    // See: https://code.google.com/p/android/issues/detail?id=1630
                    // Workaround: http://stackoverflow.com/questions/1954434/cover-art-on-android

                    int albumNameColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AlbumColumns.Album);
                    int albumArtistColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AlbumColumns.Artist);
                    int albumIdColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AlbumColumns.AlbumId);
                    int genreColumn = musicCursor.GetColumnIndex(MediaStore.Audio.GenresColumns.Name); // Also broken :(

                    int artistColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AudioColumns.Artist);
                    int titleColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AudioColumns.Title);
                    int durationColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AudioColumns.Duration);
                    int assetIdColumn = musicCursor.GetColumnIndex(MediaStore.Audio.AudioColumns.Id);

                    if (titleColumn == -1 || durationColumn == -1 || assetIdColumn == -1)
                    {
                        Debug.WriteLine("Missing essential properties from music library. Returning empty library.");
                        albumCollection = new AlbumCollection(albumList);
                        songCollection = new SongCollection(songList);
                        return;
                    }

                    for (musicCursor.MoveToFirst(); !musicCursor.IsAfterLast; musicCursor.MoveToNext())
                        try
                        {
                            long durationProperty = musicCursor.GetLong(durationColumn);
                            TimeSpan duration = TimeSpan.FromMilliseconds(durationProperty);

                            // Exclude sound effects
                            if (duration < MinimumSongDuration)
                                continue;

                            string albumNameProperty = (albumNameColumn > -1 ? musicCursor.GetString(albumNameColumn) : null) ?? "Unknown Album";
                            string albumArtistProperty = (albumArtistColumn > -1 ? musicCursor.GetString(albumArtistColumn) : null) ?? "Unknown Artist";
                            string genreProperty = (genreColumn > -1 ? musicCursor.GetString(genreColumn) : null) ?? "Unknown Genre";
                            string artistProperty = (artistColumn > -1 ? musicCursor.GetString(artistColumn) : null) ?? "Unknown Artist";
                            string titleProperty = musicCursor.GetString(titleColumn);

                            long assetId = musicCursor.GetLong(assetIdColumn);
                            var assetUri = ContentUris.WithAppendedId(MediaStore.Audio.Media.ExternalContentUri, assetId);
                            long albumId = albumIdColumn > -1 ? musicCursor.GetInt(albumIdColumn) : -1;
                            var albumArtUri = albumId > -1 ? ContentUris.WithAppendedId(Uri.Parse("content://media/external/audio/albumart"), albumId) : null;

                            Artist artist;
                            if (!artists.TryGetValue(artistProperty, out artist))
                            {
                                artist = new Artist(artistProperty);
                                artists.Add(artist.Name, artist);
                            }

                            Artist albumArtist;
                            if (!artists.TryGetValue(albumArtistProperty, out albumArtist))
                            {
                                albumArtist = new Artist(albumArtistProperty);
                                artists.Add(albumArtist.Name, albumArtist);
                            }

                            Genre genre;
                            if (!genres.TryGetValue(genreProperty, out genre))
                            {
                                genre = new Genre(genreProperty);
                                genres.Add(genre.Name, genre);
                            }

                            Album album;
                            if (!albums.TryGetValue(albumNameProperty, out album))
                            {
                                album = new Album(new SongCollection(), albumNameProperty, albumArtist, genre, albumArtUri);
                                albums.Add(album.Name, album);
                                albumList.Add(album);
                            }

                            var song = new Song(album, artist, genre, titleProperty, duration, assetUri);
                            song.Album.Songs.Add(song);
                            songList.Add(song);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("MediaLibrary exception: " + e.Message);
                        }
                }

                musicCursor.Close();
            }

            albumCollection = new AlbumCollection(albumList);
            songCollection = new SongCollection(songList);
        }
示例#26
0
        private void PlatformLoad(Action <int> progressCallback)
        {
            Task.Run(async() =>
            {
                if (musicFolder == null)
                {
                    musicFolder = KnownFolders.MusicLibrary;
                }

                var files = new List <StorageFile>();
                await this.GetAllFiles(musicFolder, files);

                var songList  = new List <Song>();
                var albumList = new List <Album>();

                var artists = new Dictionary <string, Artist>();
                var albums  = new Dictionary <string, Album>();
                var genres  = new Dictionary <string, Genre>();

                var cache = new Dictionary <string, MusicProperties>();

                // Read cache
                var cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.OpenIfExists);
                using (var stream = new BinaryReader(await cacheFile.OpenStreamForReadAsync()))
                    try
                    {
                        for (; stream.BaseStream.Position < stream.BaseStream.Length;)
                        {
                            var entry = MusicProperties.Deserialize(stream);
                            cache.Add(entry.Path, entry);
                        }
                    }
                    catch { }

                // Write cache
                cacheFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(CacheFile, CreationCollisionOption.ReplaceExisting);
                using (var stream = new BinaryWriter(await cacheFile.OpenStreamForWriteAsync()))
                {
                    int prevProgress = 0;

                    for (int i = 0; i < files.Count; i++)
                    {
                        var file = files[i];
                        try
                        {
                            MusicProperties properties;
                            if (!(cache.TryGetValue(file.Path, out properties) && properties.TryMatch(file)))
                            {
                                properties = new MusicProperties(file);
                            }
                            properties.Serialize(stream);

                            if (string.IsNullOrWhiteSpace(properties.Title))
                            {
                                continue;
                            }

                            Artist artist;
                            if (!artists.TryGetValue(properties.Artist, out artist))
                            {
                                artist = new Artist(properties.Artist);
                                artists.Add(artist.Name, artist);
                            }

                            Artist albumArtist;
                            if (!artists.TryGetValue(properties.AlbumArtist, out albumArtist))
                            {
                                albumArtist = new Artist(properties.AlbumArtist);
                                artists.Add(albumArtist.Name, albumArtist);
                            }

                            Genre genre;
                            if (!genres.TryGetValue(properties.Genre, out genre))
                            {
                                genre = new Genre(properties.Genre);
                                genres.Add(genre.Name, genre);
                            }

                            Album album;
                            if (!albums.TryGetValue(properties.Album, out album))
                            {
                                var thumbnail = Task.Run(async() => await properties.File.GetThumbnailAsync(ThumbnailMode.MusicView, 300, ThumbnailOptions.ResizeThumbnail)).Result;
                                album         = new Album(new SongCollection(), properties.Album, albumArtist, genre, thumbnail.Type == ThumbnailType.Image ? thumbnail : null);
                                albums.Add(album.Name, album);
                                albumList.Add(album);
                            }

                            var song = new Song(album, artist, genre, properties);
                            song.Album.Songs.Add(song);
                            songList.Add(song);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("MediaLibrary exception: " + e.Message);
                        }

                        int progress = 100 * i / files.Count;
                        if (progress > prevProgress)
                        {
                            prevProgress = progress;
                            if (progressCallback != null)
                            {
                                progressCallback.Invoke(progress);
                            }
                        }
                    }
                }

                if (progressCallback != null)
                {
                    progressCallback.Invoke(100);
                }

                albumCollection = new AlbumCollection(albumList);
                songCollection  = new SongCollection(songList);
            }).Wait();
        }