private void LoadImageUrls(Album album)
        {
            this.IsEmpty = false; NotifyPropertyChanged("IsEmpty");
            this.IsLoading = true; NotifyPropertyChanged("IsLoading");

            //var client = new HttpClient();

            //var urls = await XboxMusicAlbumCover.TryGetAlbumUrl(client, album.Name, album.Artist);
            //if (urls == null)
            //    return;

            //foreach (var url in urls)
            //{

            //    var image = new WriteableBitmap(480, 480);

            //    using (var inStream = (await client.GetInputStreamAsync(new Uri(url))).AsStreamForRead())
            //    using (var memoryStream = new MemoryStream())
            //    {
            //        await inStream.CopyToAsync(memoryStream);
            //        memoryStream.Seek(0, SeekOrigin.Begin);
            //        await image.SetSourceAsync(memoryStream.AsRandomAccessStream());
            //    }

            //    this.Images.Add(image);
            //}

            this.IsLoading = false; NotifyPropertyChanged("IsLoading");
            this.IsEmpty = !this.Images.Any(); NotifyPropertyChanged("IsEmpty");
        }
示例#2
0
        public AlbumViewModel(MusicLibrary library, Album album)
        {
            this.Album = album;
            this.library = library;
            library.PropertyChanged += library_PropertyChanged;

            if (library.Songs != null) LoadSongs();
        }
        public AlbumCoverFetchViewModel(Album album)
        {
            this.AlbumArtistAndName = album.ArtistAndAlbum;

            this.Images = new ObservableCollection<WriteableBitmap>();
            this.album = album;

            LoadImageUrls(album);
        }
示例#4
0
        async void audioControls_CurrentSongChanged(object sender, CurrentSongChangedEventArgs e)
        {
            var library = this.library ?? await libraryLoadingTask;

            var currentSongFileName = ApplicationSettings.CurrentSongFileName.Read();

            if (currentSongFileName == null)
            {
                this.NowPlaying = null;
            }
            else
            {
                var song = library.Songs.FirstOrDefault(p => p.FileName == currentSongFileName);
                this.NowPlaying = song;
                this.Playlist.UpdateSongChanged(e.Type, this.NowPlaying);
                if (SongChanged != null)
                    SongChanged(this, e.Type);

                if (this.NowPlayingAlbum == null || !this.NowPlayingAlbum.Contains(song))
                    this.NowPlayingAlbum = library.Albums.FirstOrDefault(p => p.Contains(song));
            }
        }