예제 #1
0
        public async static Task<MusicLibraryViewModel.AlbumItem> GetAlbumItemFromFolder(StorageFolder item, StorageFolderQueryResult albumQueryResult, int artistId)
        {
            var albumDataRepository = new AlbumDataRepository();
            var musicAttr = await item.Properties.GetMusicPropertiesAsync();

            var albumItem = await albumDataRepository.LoadAlbumViaName(artistId, musicAttr.Album);
            if (albumItem == null)
            {
                var thumbnail = await item.GetThumbnailAsync(ThumbnailMode.MusicView, 250);

                albumItem = new MusicLibraryViewModel.AlbumItem(thumbnail, musicAttr.Album, albumQueryResult.Folder.DisplayName)
                {
                    ArtistId = artistId
                };
                await albumDataRepository.Add(albumItem);
            }
            var files = await item.GetFilesAsync(CommonFileQuery.OrderByMusicProperties);
            await albumItem.LoadTracks(files);
            return albumItem;
        }
예제 #2
0
 public override async void Execute(object parameter)
 {
     var album = parameter as MusicLibraryViewModel.AlbumItem;
     if (album == null)
         return;
     // If the album is favorite, then now it is not
     // if the album was not favorite, now it is
     album.Favorite = !album.Favorite;
     var albumDataRepository = new AlbumDataRepository();
     // updating the FavoriteAlbums collection
     if (album.Favorite)
     {
         Locator.MusicLibraryVM.FavoriteAlbums.Add(album);
     }
     else if (Locator.MusicLibraryVM.FavoriteAlbums.Contains(album))
     {
         Locator.MusicLibraryVM.FavoriteAlbums.Remove(album);
     }
     // Update database;
     await albumDataRepository.Update(album);
 }