private async Task PrepareTrackAsync(Track track) { switch (track.Status) { case TrackStatus.Matching: throw new AppException("Track is still matching."); case TrackStatus.NoMatch: throw new AppException("No match found for track, try manual matching it."); case TrackStatus.NotAvailable: throw new AppException("The audio file is not available."); } if (track.Type == TrackType.Stream && track.AudioWebUri == null) { using (var blocker = new UiBlocker()) { blocker.UpdateProgress("Matching..."); var uri = await _matchEngineService.GetLinkAsync(track.Title, track.DisplayArtist); if (uri == null) { throw new AppException("Problem matching the song, try saving and manual matching it."); } track.AudioWebUri = uri.ToString(); } } }
private async void ImportExecute() { using (var blocker = UiBlocker.Show("Scanning...")) { var files = await _musicImportService.ScanFolderAsync(KnownFolders.MusicLibrary); blocker.UpdateProgress($"Importing {files.Count}..."); for (var i = 0; i < files.Count; i++) { var file = files[i]; blocker.UpdateProgress($"Importing {i + 1}/{files.Count}..."); try { await _musicImportService.SaveAsync(file); } catch { // ignored } } } }
private async void DeleteExecute() { using (UiBlocker.Show("Deleting...")) { foreach (var track in _libraryService.Tracks.Where(p => p.Type == TrackType.Local).ToList()) { await _libraryService.DeleteTrackAsync(track); } } }
private async Task <Track> ConvertToTrackAsync(WebSong webSong) { var track = webSong.PreviousConversion as Track; if (track == null) { using (var blocker = new UiBlocker()) { blocker.UpdateProgress("Getting data..."); track = await _webSongConverter.ConvertAsync(webSong); } } return(track); }
private void Awake() { UiBlocker = _UiBlocker; DontDestroyOnLoad(gameObject); Link = _Link; PrettyTextPlayer = _PrettyTextPlayer; PrettyTextRoom = _PrettyTextRoom; KeyNumberCount = _KeyNumberCount; RoomCapacity = _RoomCapacity; Check(); }
private async void DeleteExecute() { if (await MessageBox.ShowAsync("Are you sure you want to delete this post?", "Delete post", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } using (UiBlocker.Show("Deleting...")) { var restResponse = await _findierService.SendAsync(new DeletePostRequest(Post.Id)); if (restResponse.IsSuccessStatusCode) { CurtainPrompt.ShowError("Post deleted."); NavigationService.GoBack(); } else { CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error ?? "Problem deleting post."); } } }