Example #1
0
 public SongCachingChangeEvent(
     SongCachingChangeEventType eventType,
     INetworkRandomAccessStream stream,
     Song song)
     : base(eventType)
 {
     this.Stream = stream;
     this.Song   = song;
 }
Example #2
0
 private void UpdateIfSongCached(Song song, SongCachingChangeEventType eventType)
 {
     if (song != null && this.Songs != null)
     {
         var songBindingModel = this.Songs.FirstOrDefault(s => string.Equals(s.Metadata.ProviderSongId, song.ProviderSongId, StringComparison.Ordinal));
         if (songBindingModel != null)
         {
             songBindingModel.IsCached = eventType == SongCachingChangeEventType.FinishDownloading;
         }
     }
 }
        private async void OnCachingEvent(SongCachingChangeEventType eventType)
        {
            switch (eventType)
            {
            case SongCachingChangeEventType.StartDownloading:
            {
                this.isDownloading = true;
                await this.Dispatcher.RunAsync(() =>
                    {
                        this.BindingModel.ShowProgressRing = true;
                        this.BindingModel.MessageText      = "Downloading songs to local cache...";
                    });

                break;
            }

            case SongCachingChangeEventType.FailedToDownload:
            {
                this.isDownloading = false;
                await this.Dispatcher.RunAsync(() =>
                    {
                        this.BindingModel.ShowProgressRing = false;
                        this.BindingModel.MessageText      = "Error happened on download songs to local cache...";
                        this.UpdateLibraryCommand.RaiseCanExecuteChanged();
                    });

                break;
            }

            case SongCachingChangeEventType.ClearCache:
            case SongCachingChangeEventType.FinishDownloading:
            case SongCachingChangeEventType.DownloadCanceled:
            {
                this.isDownloading = false;
                await this.Dispatcher.RunAsync(() =>
                    {
                        this.BindingModel.ShowProgressRing = false;
                        this.SetOfflineMessageIfRequired();
                        this.UpdateLibraryCommand.RaiseCanExecuteChanged();
                    });

                break;
            }
            }
        }
Example #4
0
 public CachingChangeEvent(SongCachingChangeEventType eventType)
 {
     this.EventType = eventType;
 }