예제 #1
0
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            using (var db = new PodcastSqlModel())
            {
                PodcastSubscriptionModel sub = db.Subscriptions.First(s => s.PodcastId == m_subscription.PodcastId);
                sub.NewEpisodesCount = 0;
                db.SubmitChanges();
            }

            PodcastSubscriptionsManager.getInstance().NewPlayableEpisode -= new PodcastSubscriptionsManager.EpisodesEventHandler(m_subscription_NewPlayableEpisode);

            App.episodeDownloadManager.OnPodcastEpisodeDownloadStateChanged -= new PodcastDownloadManagerHandler(episodeDownloadManager_PodcastEpisodeDownloadStateChanged);
            PodcastPlaybackManager.getInstance().OnPodcastStartedPlaying -= new EventHandler(PodcastEpisodes_OnPodcastPlaystateChanged);
            PodcastPlaybackManager.getInstance().OnPodcastStoppedPlaying -= new EventHandler(PodcastEpisodes_OnPodcastPlaystateChanged);
        }
예제 #2
0
        private void stopButtonClicked(object sender, EventArgs e)
        {
            if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Stopped)
            {
                // We are already stopped (playback ended or something). Let's update the episode state.
                PodcastPlaybackManager.getInstance().CurrentlyPlayingEpisode.EpisodePlayState = PodcastEpisodeModel.EpisodePlayStateEnum.Downloaded;
            }
            else
            {
                if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing ||
                    BackgroundAudioPlayer.Instance.PlayerState == PlayState.Paused)
                {
                    BackgroundAudioPlayer.Instance.Stop();
                }
            }

            PodcastPlayer.PlaybackStopped();
        }
예제 #3
0
 private void playButtonClicked(object sender, EventArgs e)
 {
     if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing)
     {
         // Paused
         BackgroundAudioPlayer.Instance.Pause();
         PodcastPlayer.setupUIForEpisodePaused();
         //       PlayButtonImage.Source = m_playButtonBitmap;
         (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IconUri = new Uri("/Images/Light/play.png", UriKind.Relative);
         (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).Text    = "Play";
     }
     else if (BackgroundAudioPlayer.Instance.Track != null)
     {
         // Playing
         BackgroundAudioPlayer.Instance.Play();
         PodcastPlayer.setupUIForEpisodePlaying();
         //            PlayButtonImage.Source = m_pauseButtonBitmap;
         (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IconUri = new Uri("/Images/Light/pause.png", UriKind.Relative);
         (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).Text    = "Pause";
     }
     else
     {
         Debug.WriteLine("No track currently set. Trying to setup currently playing episode as track...");
         PodcastEpisodeModel ep = PodcastPlaybackManager.getInstance().CurrentlyPlayingEpisode;
         if (ep != null)
         {
             PodcastPlaybackManager.getInstance().play(ep);
         }
         else
         {
             Debug.WriteLine("Error: No currently playing track either! Giving up...");
             App.showErrorToast("Something went wrong. Cannot play the track.");
             PodcastPlayer.showNoPlayerLayout();
         }
     }
 }
예제 #4
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            m_podcastId = int.Parse(NavigationContext.QueryString["podcastId"]);
            using (var db = new PodcastSqlModel())
            {
                m_subscription = db.subscriptionModelForIndex(m_podcastId);
                m_cleanListenedEpisodesAutomatically = db.settings().IsAutoDelete;
                if (m_cleanListenedEpisodesAutomatically)
                {
                    PodcastSubscriptionsManager.getInstance().cleanListenedEpisodes(m_subscription);
                }
            }

            m_playableEpisodes = m_subscription.PlayableEpisodes;
            this.DataContext   = m_subscription;

            PodcastSubscriptionsManager.getInstance().NewPlayableEpisode     -= new PodcastSubscriptionsManager.EpisodesEventHandler(m_subscription_NewPlayableEpisode);
            PodcastSubscriptionsManager.getInstance().RemovedPlayableEpisode -= new PodcastSubscriptionsManager.EpisodesEventHandler(m_subscription_RemovedPlayableEpisode);

            PodcastSubscriptionsManager.getInstance().NewPlayableEpisode     += new PodcastSubscriptionsManager.EpisodesEventHandler(m_subscription_NewPlayableEpisode);
            PodcastSubscriptionsManager.getInstance().RemovedPlayableEpisode += new PodcastSubscriptionsManager.EpisodesEventHandler(m_subscription_RemovedPlayableEpisode);

            bool forceUpdate = false;

            try
            {
                forceUpdate = String.IsNullOrEmpty(NavigationContext.QueryString["forceUpdate"]) == false &&
                              bool.Parse(NavigationContext.QueryString["forceUpdate"]);
            }
            catch (KeyNotFoundException)
            {
                forceUpdate = false;
            }

            if (forceUpdate)
            {
                // Clear the back stack
                while (((App)Application.Current).RootFrame.RemoveBackEntry() != null)
                {
                    ;
                }

                ShellTile pinnedSubscriptionTile = m_subscription.getSubscriptionsLiveTile();
                if (pinnedSubscriptionTile != null)
                {
                    StandardTileData tileData = new StandardTileData();
                    tileData.Count     = 0;
                    tileData.BackTitle = "";
                    pinnedSubscriptionTile.Update(tileData);
                }

                PodcastSubscriptionsManager.getInstance().refreshSubscription(m_subscription);
            }

            m_subscription.PodcastCleanStarted  -= new PodcastSubscriptionModel.SubscriptionModelHandler(m_subscription_PodcastCleanStarted);
            m_subscription.PodcastCleanFinished -= new PodcastSubscriptionModel.SubscriptionModelHandler(m_subscription_PodcastCleanFinished);

            m_subscription.PodcastCleanStarted  += new PodcastSubscriptionModel.SubscriptionModelHandler(m_subscription_PodcastCleanStarted);
            m_subscription.PodcastCleanFinished += new PodcastSubscriptionModel.SubscriptionModelHandler(m_subscription_PodcastCleanFinished);

            // Clean old episodes from the listing.
            if (SettingsModel.keepNumEpisodesForSelectedIndex(m_subscription.SubscriptionSelectedKeepNumEpisodesIndex) != SettingsModel.KEEP_ALL_EPISODES)
            {
                m_subscription.cleanOldEpisodes(SettingsModel.keepNumEpisodesForSelectedIndex(m_subscription.SubscriptionSelectedKeepNumEpisodesIndex));
            }

            if (App.episodeDownloadManager == null)
            {
                App.episodeDownloadManager = PodcastEpisodesDownloadManager.getInstance();
            }

            App.episodeDownloadManager.OnPodcastEpisodeDownloadStateChanged += new PodcastDownloadManagerHandler(episodeDownloadManager_PodcastEpisodeDownloadStateChanged);

            PodcastPlaybackManager.getInstance().OnPodcastStartedPlaying += new EventHandler(PodcastEpisodes_OnPodcastPlaystateChanged);
            PodcastPlaybackManager.getInstance().OnPodcastStoppedPlaying += new EventHandler(PodcastEpisodes_OnPodcastPlaystateChanged);
        }
예제 #5
0
        private void AddDownloadedToPlayQueue_Clicked(object sender, EventArgs e)
        {
            PodcastPlaybackManager playbackManager = PodcastPlaybackManager.getInstance();

            playbackManager.addToPlayqueue(m_playableEpisodes);
        }
예제 #6
0
        protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);

            try
            {
                PodcastEpisodeModel playingEpisode = m_subscription.EpisodesPublishedDescending.Where(ep => ep.EpisodeId == PodcastPlaybackManager.getInstance().CurrentlyPlayingEpisode.EpisodeId).FirstOrDefault();
                if (playingEpisode != null)
                {
                    playingEpisode.setNoPlaying();
                }
            }
            catch (NullReferenceException)
            {
                Debug.WriteLine("No episode playing.");
            }
        }