Exemplo n.º 1
0
        private async void LoginButtonClick(object sender, RoutedEventArgs e)
        {
            var username = UsernameBox.Text;
            var password = PasswordBox.Password;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                CurtainPrompt.ShowError("Looks like you forgot your email/password.");
            }
            else
            {
                App.SupressBackEvent -= HardwareButtonsOnBackPressed;
                UiBlockerUtility.Block("Signing in...");

                var regResp = await App.Locator.AudioticaService.LoginAsync(username, password);

                if (regResp.Success)
                {
                    emailTask.SetResult(true);
                    emailTask = null;
                }
                else
                {
                    App.SupressBackEvent += HardwareButtonsOnBackPressed;
                    CurtainPrompt.ShowError(regResp.Message ?? "Problem signing you in.");
                }

                UiBlockerUtility.Unblock();
            }
        }
Exemplo n.º 2
0
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as AppBarButton;
            var name   = PlaylistNameText.Text;

            button.IsEnabled           = false;
            PlaylistNameText.IsEnabled = false;

            if (string.IsNullOrEmpty(name))
            {
                CurtainPrompt.ShowError("PlaylistCreateNameForgot".FromLanguageResource());
            }
            else
            {
                if (App.Locator.CollectionService.
                    Playlists.FirstOrDefault(p =>
                                             String.Equals(p.Name, name, StringComparison.CurrentCultureIgnoreCase)) != null)
                {
                    CurtainPrompt.ShowError("PlaylistCreateNameTaken".FromLanguageResource());
                }
                else
                {
                    var playlist = await App.Locator.CollectionService.CreatePlaylistAsync(name);

                    CurtainPrompt.Show("PlaylistCreateSuccess".FromLanguageResource(), playlist.Name);
                    App.Navigator.GoBack();
                }
            }

            button.IsEnabled           = true;
            PlaylistNameText.IsEnabled = true;
        }
Exemplo n.º 3
0
        public async void PlaySong(QueueSong song)
        {
            if (song == null || song.Song == null)
            {
                CurtainPrompt.ShowError("Song seems to be empty...");
                return;
            }

            Insights.Track(
                "Play Song",
                new Dictionary <string, string>
            {
                { "Name", song.Song.Name },
                { "ArtistName", song.Song.ArtistName },
                { "ProviderId", song.Song.ProviderId }
            });

            if (_isShutdown)
            {
                await AddMediaPlayerEventHandlers();
            }

            _appSettings.Write("RadioId", null);
            _appSettings.Write("RadioMode", false);
            _appSettings.Write(PlayerConstants.CurrentTrack, song.Id);

            var message = new ValueSet {
                { PlayerConstants.StartPlayback, null }
            };

            BackgroundMediaPlayer.SendMessageToBackground(message);

            RaiseEvent(TrackChanged);
        }
Exemplo n.º 4
0
        public async void LoadData(string name)
        {
            IsLoading = true;

            Artist = await _service.GetDetailArtist(name);

            if (Artist == null)
            {
                CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
            }
            try
            {
                TopTracks = (await _service.GetArtistTopTracks(name)).Content.ToList();
            }
            catch
            {
                CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
            }

            try
            {
                TopAlbums = (await _service.GetArtistTopAlbums(name)).Content.ToList();
            }
            catch
            {
                CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
            }

            IsLoading = false;
        }
Exemplo n.º 5
0
        private async void ResetButton_Click(object sender, RoutedEventArgs e)
        {
            if (App.Locator.Download.ActiveDownloads.Count > 0)
            {
                CurtainPrompt.ShowError("Can't do a reset while there are active downloads.");
                return;
            }

            if (
                await
                MessageBox.ShowAsync(
                    "This will delete completely all your downloaded and saved songs, along with their artwork. Imported songs will only be removed from the app.",
                    "ARE YOU SURE?",
                    MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }

            await
            MessageBox.ShowAsync(
                "To continue with the factory reset the app will shutdown and continue once you open it again.",
                "Application Restart Required");


            App.Locator.AppSettingsHelper.Write("FactoryReset", true);
            App.Locator.AppSettingsHelper.Write("LastSyncTime", null);
            App.Locator.AudioPlayerHelper.FullShutdown();
            App.Locator.SqlService.Dispose();
            App.Locator.BgSqlService.Dispose();
            Application.Current.Exit();
        }
Exemplo n.º 6
0
        private async void RestoreButton_Click(object sender, RoutedEventArgs e)
        {
            if (App.Locator.Download.ActiveDownloads.Count > 0)
            {
                CurtainPrompt.ShowError("Can't do a restore while there are active downloads.");
                return;
            }

            if (
                await
                MessageBox.ShowAsync(
                    "This will delete all your pre-existing data.",
                    "Continue with Restore?",
                    MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            var fileOpenPicker = new FileOpenPicker {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            fileOpenPicker.FileTypeFilter.Add(".autcp");
            fileOpenPicker.PickSingleFileAndContinue();
        }
Exemplo n.º 7
0
        private async void LoginButtonClick(object sender, RoutedEventArgs e)
        {
            var username = UserBox.Text;
            var email    = EmailBox.Text;
            var password = PasswordBox.Password;

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                CurtainPrompt.ShowError("Looks like you forgot to fill out everything.");
            }
            else
            {
                App.SupressBackEvent -= HardwareButtonsOnBackPressed;
                UiBlockerUtility.Block("Creating account...");

                var regResp = await App.Locator.AudioticaService.RegisterAsync(username, password, email);

                if (regResp.Success)
                {
                    emailTask.SetResult(true);
                    emailTask = null;
                }
                else
                {
                    App.SupressBackEvent += HardwareButtonsOnBackPressed;
                    CurtainPrompt.ShowError(regResp.Message ?? "Problem creating account.");
                }

                UiBlockerUtility.Unblock();
            }
        }
Exemplo n.º 8
0
        public override async void OnNavigatedTo(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var albumParameter = (AlbumPageParameter)parameter;

            IsCatalogMode = albumParameter.IsCatalogMode;

            if (!IsCatalogMode && albumParameter.Title != null)
            {
                Album = _libraryService.Albums.FirstOrDefault(p =>
                                                              p.Title.EqualsIgnoreCase(albumParameter.Title) &&
                                                              p.Artist.Name.EqualsIgnoreCase(albumParameter.Artist));
            }
            if (Album == null)
            {
                try
                {
                    await LoadAsync(albumParameter);
                }
                catch
                {
                    // ignored
                }

                if (Album == null)
                {
                    CurtainPrompt.ShowError("Problem loading album");
                    return;
                }
            }

            if (_settingsUtility.Read(ApplicationSettingsConstants.IsAlbumAdaptiveColorEnabled, true))
            {
                DetectColorFromArtwork();
            }
        }
Exemplo n.º 9
0
        private async void LoginExecute()
        {
            IsLoading = true;
            var restResponse = await _findierService.LoginAsync(new OAuthRequest(Username, Password));

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("Welcome!");

                if (_requireAuthentication)
                {
                    // return to original page that requested authentication
                    NavigationService.Frame.BackStack.RemoveAt(NavigationService.Frame.BackStack.Count - 1);
                    NavigationService.GoBack();
                }
                else
                {
                    NavigationService.Navigate(typeof(MainPage), clearBackStack: true);
                }
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error
                                        ?? "Problem with login. Try again later.");
            }
        }
Exemplo n.º 10
0
        private async void PublishExecute()
        {
            if (string.IsNullOrWhiteSpace(Text))
            {
                CurtainPrompt.ShowError("Looks like you forgot to include some text.");
                return;
            }

            var newCommentRequest = new CreateCommentRequest(_postId, Text);

            IsLoading = true;
            var restResponse = await _findierService.SendAsync <CreateCommentRequest, string>(newCommentRequest);

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("Comment published!");
                NavigationService.GoBack();
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error ?? "Problem publishing comment.");
            }
        }
Exemplo n.º 11
0
        public async Task StartDownloadAsync(Song song)
        {
            song.SongState = SongState.Downloading;

            try
            {
                var path = string.Format("songs/{0}.mp3", song.Id);

                var destinationFile =
                    await
                    WinRtStorageHelper.CreateFileAsync(path, ApplicationData.Current.LocalFolder,
                                                       CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);

                var downloader = new BackgroundDownloader();
                var download   = downloader.CreateDownload(new Uri(song.AudioUrl), destinationFile);
                download.Priority = BackgroundTransferPriority.High;
                song.DownloadId   = download.Guid.ToString();

                await sqlService.UpdateItemAsync(song).ConfigureAwait(false);

                dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => HandleDownload(song, download, true));
            }
            catch (Exception e)
            {
                if (e.Message.Contains("there is not enough space on the disk"))
                {
                    dispatcher.RunAsync(
                        CoreDispatcherPriority.Normal,
                        () => CurtainPrompt.ShowError("Not enough disk space to download."));
                }

                dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => song.SongState = SongState.None);
                sqlService.UpdateItemAsync(song).ConfigureAwait(false);
            }
        }
Exemplo n.º 12
0
        private async void AddCollection_Click(object sender, RoutedEventArgs e)
        {
            var button = (MenuFlyoutItem)sender;

            button.IsEnabled = false;

            using (var scope = App.Current.Kernel.BeginScope())
            {
                var trackSaveService = scope.Resolve <ITrackSaveService>();

                try
                {
                    await trackSaveService.SaveAsync(Track);
                }
                catch (AppException ex)
                {
                    Track.Status = TrackStatus.None;
                    CurtainPrompt.ShowError(ex.Message ?? "Problem saving: " + Track);
                }
                finally
                {
                    button.IsEnabled = true;
                }
            }
        }
Exemplo n.º 13
0
        private async void DeleteButtonOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            var button = sender as AppBarButton;

            button.IsEnabled   = false;
            SongList.IsEnabled = false;

            var songs = SongList.SelectedItems.ToList();

            if (songs.Count == 0)
            {
                CurtainPrompt.ShowError("SongsNoneSelected".FromLanguageResource());
            }
            else
            {
                foreach (var song in songs)
                {
                    var playlist = (DataContext as CollectionPlaylistViewModel).Playlist;
                    await App.Locator.CollectionService.DeleteFromPlaylistAsync(playlist, song as PlaylistSong);
                }
                ToSingleMode();
            }

            button.IsEnabled   = true;
            SongList.IsEnabled = true;
        }
Exemplo n.º 14
0
        private IncrementalObservableCollection <T> CreateLastIncrementalCollection <T>(
            Func <PageResponse <T> > getPageResponse,
            Action <PageResponse <T> > setPageResponse,
            Func <int, Task <PageResponse <T> > > searchFunc) where T : new()
        {
            var collection = new IncrementalObservableCollection <T>
            {
                HasMoreItemsFunc = () =>
                {
                    var page = getPageResponse();
                    if (page != null)
                    {
                        return(page.Page < page.TotalPages);
                    }

                    return(false);
                }
            };

            collection.LoadMoreItemsFunc = count =>
            {
                Func <Task <LoadMoreItemsResult> > taskFunc = async() =>
                {
                    try
                    {
                        IsLoading = true;

                        var pageResp = getPageResponse();
                        var resp     = await searchFunc(pageResp.Page + 1);

                        foreach (var item in resp.Content)
                        {
                            collection.Add(item);
                        }

                        IsLoading = false;

                        setPageResponse(resp);

                        return(new LoadMoreItemsResult {
                            Count = (uint)resp.Content.Count
                        });
                    }
                    catch
                    {
                        IsLoading = false;
                        setPageResponse(null);
                        CurtainPrompt.ShowError("GenericLoadingMoreError".FromLanguageResource());
                        return(new LoadMoreItemsResult {
                            Count = 0
                        });
                    }
                };
                var loadMorePostsTask = taskFunc();
                return(loadMorePostsTask.AsAsyncOperation());
            };
            return(collection);
        }
Exemplo n.º 15
0
 private void StreamManagerOnError(object sender, EventArgs eventArgs)
 {
     _torrentStreamService.Stop();
     _dispatcherUtility.Run(() =>
     {
         CurtainPrompt.ShowError("Problem starting playback.");
         _navigationService.GoBack();
     });
 }
Exemplo n.º 16
0
 protected override bool OnUnhandledException(Exception ex)
 {
     CurtainPrompt.ShowError("Crash prevented",
                             () =>
     {
         MessageBox.Show(
             "The problem has been reported.  If you continue to experience this bug, email support.  Details: " +
             ex.Message,
             "Crash prevented");
     });
     return(true);
 }
Exemplo n.º 17
0
        private async void SearchAlbums(string query, ISearchMetadataProvider provider)
        {
            try
            {
                AlbumsResults = null;
                var result = await provider.SearchAsync(query, WebResults.Type.Album);

                AlbumsResults = await _webToAlbumConverter.FillPartialAsync(result?.Albums);
            }
            catch
            {
                CurtainPrompt.ShowError("Something happened while searching for albums!");
            }
        }
Exemplo n.º 18
0
        private async void SearchArtists(string query, ISearchMetadataProvider provider)
        {
            try
            {
                ArtistsResults = null;
                var result = await provider.SearchAsync(query, WebResults.Type.Artist);

                ArtistsResults = result?.Artists;
            }
            catch
            {
                CurtainPrompt.ShowError("Something happened while searching for artists!");
            }
        }
Exemplo n.º 19
0
        private async void SearchTracks(string query, ISearchMetadataProvider provider)
        {
            try
            {
                TracksResults = null;
                var result = await provider.SearchAsync(query);

                TracksResults = await _webToTrackConverter.ConvertAsync(result?.Songs);
            }
            catch
            {
                CurtainPrompt.ShowError("Something happened while searching for tracks!");
            }
        }
Exemplo n.º 20
0
        private async void KeyDownExecute(KeyRoutedEventArgs e)
        {
            if (e.Key != VirtualKey.Enter)
            {
                return;
            }

            _tracksResponse = null;

            // Close the keyboard
            ((Page)((Grid)((TextBox)e.OriginalSource).Parent).Parent).Focus(FocusState.Keyboard);

            var term = ((TextBox)e.OriginalSource).Text;

            term = term.Trim();
            if (term.StartsWith("http://www.last.fm/music/") && term.Contains("/_/"))
            {
                CurtainPrompt.Show("Last.fm link detected.");
                term = term.Replace("http://www.last.fm/music/", string.Empty);
                var artist = term.Substring(0, term.IndexOf("/_/"));
                var title  = WebUtility.UrlDecode(term.Replace(artist + "/_/", string.Empty));
                artist = WebUtility.UrlDecode(artist);
                try
                {
                    var track = await _service.GetDetailTrack(title, artist);

                    if (track == null)
                    {
                        CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
                    }
                    else
                    {
                        await CollectionHelper.SaveTrackAsync(track);
                    }
                }
                catch
                {
                    CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
                }
            }
            else
            {
                ((TextBox)e.OriginalSource).IsEnabled = false;
                IsLoading = true;
                await SearchAsync(term);

                ((TextBox)e.OriginalSource).IsEnabled = true;
                IsLoading = false;
            }
        }
Exemplo n.º 21
0
        private async void Import()
        {
            using (var handle = Insights.TrackTime("Import Music"))
            {
                UiBlockerUtility.Block("Scanning...");
                var localMusic = await LocalMusicHelper.GetFilesInMusicAsync();

                handle.Data.Add("TotalCount", localMusic.Count.ToString());
                var failedCount = 0;

                App.Locator.CollectionService.Songs.SuppressEvents   = true;
                App.Locator.CollectionService.Artists.SuppressEvents = true;
                App.Locator.CollectionService.Albums.SuppressEvents  = true;

                App.Locator.SqlService.BeginTransaction();
                for (var i = 0; i < localMusic.Count; i++)
                {
                    StatusBarHelper.ShowStatus(
                        string.Format("Importing {0} of {1} items", i + 1, localMusic.Count),
                        (double)i / localMusic.Count);
                    try
                    {
                        await LocalMusicHelper.SaveTrackAsync(localMusic[i]);
                    }
                    catch
                    {
                        failedCount++;
                    }
                }

                App.Locator.SqlService.Commit();

                App.Locator.CollectionService.Songs.Reset();
                App.Locator.CollectionService.Artists.Reset();
                App.Locator.CollectionService.Albums.Reset();

                UiBlockerUtility.Unblock();

                if (failedCount > 0)
                {
                    CurtainPrompt.ShowError("Couldn't import {0} song(s).", failedCount);
                    handle.Data.Add("Failed", failedCount.ToString());
                }
            }

            await CollectionHelper.DownloadAlbumsArtworkAsync();

            await CollectionHelper.DownloadArtistsArtworkAsync();
        }
Exemplo n.º 22
0
        public async Task StartDownloadAsync(Track track)
        {
            track.Status = TrackStatus.Downloading;

            try
            {
                // first create the final destination path (after download finishes)
                var downloadsPath = _appSettingsUtility.DownloadsPath;

                var path = track.AlbumArtist.ToSanitizedFileName() + "/" +
                           track.AlbumTitle.ToSanitizedFileName() + "/";
                var filename = track.Title.ToSanitizedFileName();

                if (track.DisplayArtist != track.AlbumArtist)
                {
                    filename = filename + "-" + track.DisplayArtist.ToSanitizedFileName();
                }

                track.AudioLocalUri = downloadsPath + path + filename + ".mp3";

                // now the temp file
                var saveFolder = await StorageFolder.GetFolderFromPathAsync(_appSettingsUtility.TempDownloadsPath);

                var tempFileName    = $"{track.Id}.mp3";
                var destinationFile =
                    await
                    StorageHelper.CreateFileAsync(tempFileName, saveFolder, CreationCollisionOption.ReplaceExisting);

                // create the downloader
                var downloader = new BackgroundDownloader();
                var download   = downloader.CreateDownload(new Uri(track.AudioWebUri), destinationFile);
                download.Priority = BackgroundTransferPriority.Default;

                // start handling it
                HandleDownload(track, download, true);

                // save changes to db
                await _libraryService.UpdateTrackAsync(track);
            }
            catch (Exception e)
            {
                if (e.Message.Contains("there is not enough space on the disk"))
                {
                    CurtainPrompt.ShowError("Not enough disk space to download.");
                }
                track.Status = TrackStatus.None;
                await _libraryService.UpdateTrackAsync(track);
            }
        }
Exemplo n.º 23
0
 private async void SaveAllExecute(object sender)
 {
     foreach (var track in Album.Tracks.Where(p => !p.IsFromLibrary))
     {
         try
         {
             await _trackSaveService.SaveAsync(track);
         }
         catch (AppException ex)
         {
             track.Status = TrackStatus.None;
             CurtainPrompt.ShowError(ex.Message ?? "Problem saving: " + track);
         }
     }
 }
Exemplo n.º 24
0
        private void HandleAction(SpotlightFeature feature)
        {
            var action    = feature.Action.Substring(feature.Action.IndexOf(":", StringComparison.Ordinal) + 1);
            var supported = true;

            if (feature.Action.StartsWith("web:"))
            {
                Launcher.LaunchUriAsync(new Uri(action));
            }
            else if (feature.Action.StartsWith("artist:"))
            {
                App.Navigator.GoTo <SpotifyArtistPage, ZoomInTransition>("name." + action);
            }
            else if (feature.Action.StartsWith("page:"))
            {
                switch (action)
                {
                case "cloud":
                    App.Navigator.GoTo <CloudPage, ZoomOutTransition>(null);
                    break;

                case "lastfm":
                    App.Navigator.GoTo <LastFmPage, ZoomOutTransition>(null);
                    break;

                default:
                    if (action.StartsWith("search:"))
                    {
                        action = action.Substring(feature.Action.IndexOf(":", StringComparison.Ordinal) + 1);
                        App.Navigator.GoTo <SearchPage, ZoomInTransition>(action);
                    }
                    else
                    {
                        supported = false;
                    }
                    break;
                }
            }
            else
            {
                supported = false;
            }

            if (!supported)
            {
                CurtainPrompt.ShowError("Audiotica can't open this type of link.  Try updating in the store.");
            }
        }
Exemplo n.º 25
0
        private async void AddUpNext_Click(object sender, RoutedEventArgs e)
        {
            using (var scope = App.Current.Kernel.BeginScope())
            {
                var backgroundAudioService = scope.Resolve <IPlayerService>();
                try
                {
                    await backgroundAudioService.AddUpNextAsync(Track);

                    CurtainPrompt.Show("Added up next");
                }
                catch (AppException ex)
                {
                    CurtainPrompt.ShowError(ex.Message ?? "Something happened.");
                }
            }
        }
Exemplo n.º 26
0
        private async void LoginButtonClicked()
        {
            if (IsLoggedIn)
            {
                _service.Logout();
                CurtainPrompt.Show("AuthLogoutSuccess".FromLanguageResource());
                LastFmUsername = null;
                LastFmPassword = null;
                IsLoggedIn     = false;
                Scrobble       = false;
                Insights.Track("Logged out from Last.FM");
            }
            else
            {
                if (string.IsNullOrEmpty(LastFmUsername) ||
                    string.IsNullOrEmpty(LastFmPassword))
                {
                    CurtainPrompt.ShowError("AuthLoginErrorForgot".FromLanguageResource());
                }

                else
                {
                    UiBlockerUtility.Block("GenericWait".FromLanguageResource());
                    if (await _service.AuthenticaAsync(LastFmUsername, LastFmPassword))
                    {
                        CurtainPrompt.Show("AuthLoginSuccess".FromLanguageResource());
                        IsLoggedIn = true;
                        Scrobble   = true;
                        Insights.Track("Logged in Last.FM");
                    }
                    else
                    {
                        CurtainPrompt.ShowError("AuthLoginError".FromLanguageResource());
                    }
                    UiBlockerUtility.Unblock();
                }

                // update the player also
                var msg = new ValueSet {
                    { PlayerConstants.LastFmLoginChanged, string.Empty }
                };
                BackgroundMediaPlayer.SendMessageToBackground(msg);
            }
        }
Exemplo n.º 27
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.FirstOrDefault();

            if (file == null)
            {
                CurtainPrompt.ShowError("No backup file picked.");
                return;
            }

            UiBlockerUtility.Block("Preparing...");
            App.Locator.AudioPlayerHelper.FullShutdown();
            App.Locator.SqlService.Dispose();
            App.Locator.BgSqlService.Dispose();

            using (var stream = await file.OpenStreamForReadAsync())
            {
                if (AutcpFormatHelper.ValidateHeader(stream))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    var restoreFile = await StorageHelper.CreateFileAsync("_current_restore.autcp");

                    using (var restoreStream = await restoreFile.OpenAsync(FileAccess.ReadAndWrite))
                    {
                        await stream.CopyToAsync(restoreStream);
                    }

                    UiBlockerUtility.Unblock();

                    await
                    MessageBox.ShowAsync(
                        "To finish applying the restore the app will close. Next time you start the app, it will finish restoring.",
                        "Application Restart Required");

                    App.Locator.AppSettingsHelper.Write("Restore", true);
                    Application.Current.Exit();
                }
                else
                {
                    CurtainPrompt.ShowError("Not a valid backup file.");
                }
            }
        }
Exemplo n.º 28
0
        private async void LoadData(string id)
        {
            IsLoading = true;

            try
            {
                Album = await _service.GetAlbumAsync(id);

                foreach (var simpleTrack in Album.Tracks.Items)
                {
                    simpleTrack.Artist = Album.Artists[0];
                }
                Tracks = new ObservableCollection <SimpleTrack>(Album.Tracks.Items);
            }
            catch
            {
                CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
            }
            IsLoading = false;
        }
Exemplo n.º 29
0
        private async void AddUpNext_Click(object sender, RoutedEventArgs e)
        {
            using (var scope = App.Current.Kernel.BeginScope())
            {
                var backgroundAudioService = scope.Resolve <IPlayerService>();
                try
                {
                    var tracks = GetTracks()
                                 .Where(p => p.Status == TrackStatus.None || p.Status == TrackStatus.Downloading)
                                 .ToList();
                    await backgroundAudioService.AddUpNextAsync(tracks);

                    CurtainPrompt.Show("Added up next");
                }
                catch (AppException ex)
                {
                    CurtainPrompt.ShowError(ex.Message ?? "Something happened.");
                }
            }
        }
Exemplo n.º 30
0
        public override async void OnNavigatedTo(object parameter, NavigationMode mode, Dictionary <string, object> state)
        {
            if (state.ContainsKey("movie"))
            {
                Movie = state["movie"] as YtsMovieFull;
            }

            if (Movie == null)
            {
                IsLoading = true;
                var id       = uint.Parse(parameter.ToString());
                var response = await new MovieDetailsRequest(id).WithCast().WithImages().ToResponseAsync();
                IsLoading = false;
                if (response.IsSuccessStatusCode)
                {
                    Movie = response.DeserializedResponse.Data;
                }
                else
                {
                    _navigationService.GoBack();
                    CurtainPrompt.ShowError(response.DeserializedResponse?.StatusMessage ??
                                            "Problem loading movie details.");
                }
            }

            if (Movie != null)
            {
                var high = Movie.Torrents.FirstOrDefault(p => p.Quality == VideoQuality.Q1080);
                var low  = Movie.Torrents.FirstOrDefault(p => p.Quality == VideoQuality.Q720);
                if (high != null)
                {
                    Is1080 = true;
                    IsQualityToggleEnabled = low != null;
                    SelectedTorrent        = high;
                }
                else
                {
                    SelectedTorrent = low;
                }
            }
        }