Exemple #1
0
        private async void btnSpara_Click(object sender, EventArgs e)
        {
            try
            {
                urlValiderare.ValideraInput(txtURL.Text);
                comboboxValiderare.ValideraInput((string)cbFrekvens.SelectedItem);
                comboboxValiderare.ValideraInput((string)cbKategori.SelectedItem);

                var document = await PodcastFetcher.FetchPodcastAsync(txtURL.Text);

                var title        = document.SelectSingleNode("rss/channel/title");
                var avsnittLista = document.SelectNodes("rss/channel/item");

                SetPodcastValues(valdPodcast, title.InnerText, avsnittLista.Count);
                PodcastHelper.SetAvsnitt(valdPodcast, avsnittLista);

                UpdatePodcastListan();
                PodcastStorage.SavePodcasts(PodcastLista);

                valdPodcast.uppdateringsTimer.Stop();
                StartaTimer(valdPodcast);

                ClearPodcastInputs();
            }
            catch (Exception ex)
            {
                ErrorHandler.HanteraFel(ex);
            }
        }
        public override Uri MapUri(Uri uri)
        {
            if (PodcastHelper.HasPodcastUri(uri))
            {
                BackgroundAudioPlayer bap = BackgroundAudioPlayer.Instance;
                var action = PodcastHelper.RetrievePodcastAction(uri);

                switch (action.Command)
                {
                case PodcastCommand.Launch:
                    // Do nothing.
                    break;

                case PodcastCommand.Pause:
                    if (bap.CanPause)
                    {
                        bap.Pause();
                    }
                    break;

                case PodcastCommand.Play:
                    if (bap.PlayerState != PlayState.Playing)
                    {
                        PodcastPlaybackManager.getInstance().startDefaultBehaviorPlayback();
                    }
                    break;

                case PodcastCommand.SkipNext:
                    if (bap.PlayerState == PlayState.Playing)
                    {
                        bap.SkipNext();
                    }
                    break;

                case PodcastCommand.SkipPrevious:
                    if (bap.PlayerState == PlayState.Playing)
                    {
                        bap.SkipPrevious();
                    }
                    break;
                }

                return(new Uri("/Views/MainView.xaml", UriKind.Relative));
            }
            // Otherwise perform normal launch.
            return(uri);
        }
Exemple #3
0
        private void StartaTimer(Podcast p)
        {
            p.uppdateringsTimer.Interval = PodcastHelper.GetUppdateringsfrekvensMilliseconds(p.Uppdateringsfrekvens);
            p.uppdateringsTimer.Tick    += async delegate
            {
                var document = await PodcastFetcher.FetchPodcastAsync(p.Url);

                var title        = document.SelectSingleNode("rss/channel/title");
                var avsnittLista = document.SelectNodes("rss/channel/item");

                p.Titel        = title.InnerText;
                p.AntalAvsnitt = avsnittLista.Count.ToString();
                PodcastHelper.SetAvsnitt(p, avsnittLista);

                UpdatePodcastListan();
                PodcastStorage.SavePodcasts(PodcastLista);
            };
            p.uppdateringsTimer.Start();
        }