Ejemplo n.º 1
0
        private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
        {
            PodcastEpisodeModel podcastEpisode = (sender as MenuItem).DataContext as PodcastEpisodeModel;

            podcastEpisode.deleteDownloadedEpisode();
            PodcastSubscriptionsManager.getInstance().removedPlayableEpisode(podcastEpisode);

            using (var db = new PodcastSqlModel())
            {
                m_episodeModel = db.episodeForEpisodeId(m_episodeModel.EpisodeId);
            }

            this.DataContext = null;
            this.DataContext = m_episodeModel;
        }
Ejemplo n.º 2
0
        private void completePodcastDownload(BackgroundTransferRequest transferRequest)
        {
            // If the status code of a completed transfer is 200 or 206, the
            // transfer was successful
            if (transferRequest.TransferError == null &&
                (transferRequest.StatusCode == 200 || transferRequest.StatusCode == 206))
            {
                Debug.WriteLine("Transfer request completed succesfully.");
                updateEpisodeWhenDownloaded(m_currentEpisodeDownload);

                // Add downloaded episode to play queue, if set.
                using (var db = new PodcastSqlModel())
                {
                    if (db.settings().IsAddDownloadsToPlayQueue)
                    {
                        PodcastPlaybackManager.getInstance().addSilentlyToPlayqueue(m_currentEpisodeDownload);
                    }
                }
            }
            else
            {
                Debug.WriteLine("Transfer request completed with error code: " + transferRequest.StatusCode + ", " + transferRequest.TransferError);
                switch (transferRequest.StatusCode)
                {
                case 0:
                    Debug.WriteLine("Request canceled.");
                    break;

                // If error code is 200 but we still got an error, this means the max. transfer size exceeded.
                // This is because the podcast feed announced a different download size than what the file actually is.
                // If user wants, we can try again with larger file download size policy.
                case 200:
                    Debug.WriteLine("Maxiumum download size exceeded. Shall we try again?");

                    if (MessageBox.Show("Podcast feed announced wrong file size. Do you want to download again with larger file download settings?",
                                        "Podcast download failed",
                                        MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        if (MessageBox.Show("Please connect your phone to an external power source and to a WiFi network.",
                                            "Attention",
                                            MessageBoxButton.OK) == MessageBoxResult.OK)
                        {
                            Debug.WriteLine("Download the same episode again, with preferences None.");

                            // We download the same file again, but this time we force the TransferPrefernces to be None.
                            startNextEpisodeDownload(TransferPreferences.None);
                            return;
                        }
                    }
                    break;

                case 301:
                    App.showErrorToast("WP8 cannot download from this location.");
                    break;

                default:
                    App.showErrorToast("Could not download the episode\nfrom the server.");
                    break;
                }


                if (m_currentEpisodeDownload != null)
                {
                    m_currentEpisodeDownload.EpisodeDownloadState = PodcastEpisodeModel.EpisodeDownloadStateEnum.Idle;
                    m_currentEpisodeDownload.deleteDownloadedEpisode();
                }
            }

            saveEpisodeInfoToDB(m_currentEpisodeDownload);
            cleanupEpisodeDownload(transferRequest);
            // And start a next round of downloading.
            startNextEpisodeDownload();
        }