コード例 #1
0
        private async Task <PodcastItem> DownloadPodcast(PodcastItem podcast)
        {
            downloadButton.Text  = @"Cancel";
            podcastsList.Enabled = false;
            _cts = new CancellationTokenSource();

            try
            {
                using (var downloader = new Downloader())
                {
                    var progress = new Progress <int>(progressPercentage => progressBar.Value = progressPercentage);
                    await downloader.DownloadPodcastAsync(podcast,
                                                          @"C:\Temp\", _cts.Token, progress);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                downloadButton.Text  = @"Download";
                podcastsList.Enabled = true;

                _cts.Dispose();
                _cts = null;
            }

            return(podcast);
        }
コード例 #2
0
        public async Task <string> AddPodcastFile(Transaction transaction, int podcastItemId)
        {
            string fileName = string.Empty;

            try
            {
                PodcastItem podcastItem = null;

                podcastItem = await dataService.Get <PodcastItem>(item => item.Id == podcastItemId, default, item => item.Podcast);
        private void OnAddClick(object sender, EventArgs e)
        {
            MessageBox.Show("Button Add work");
            PodcastItem podcast1 = new PodcastItem { Name = "My Added PodCast #1" };
            PodcastItem podcast2 = new PodcastItem { Name = "My Added PodCast #2" };

            var podcastitems = new List<PodcastItem>();
            podcastitems.Add(podcast1);
            podcastitems.Add(podcast2);

            //MyList.Items.Clear();
            //MyList.ItemsSource = podcastitems;
            MyList.DataContext = podcastitems;
            MessageBox.Show(MyList.Items.Count.ToString());
        }
コード例 #4
0
        private void OnAddClick(object sender, EventArgs e)
        {
            MessageBox.Show("Button Add work");
            PodcastItem podcast1 = new PodcastItem {
                Name = "My Added PodCast #1"
            };
            PodcastItem podcast2 = new PodcastItem {
                Name = "My Added PodCast #2"
            };

            var podcastitems = new List <PodcastItem>();

            podcastitems.Add(podcast1);
            podcastitems.Add(podcast2);

            //MyList.Items.Clear();
            //MyList.ItemsSource = podcastitems;
            MyList.DataContext = podcastitems;
            MessageBox.Show(MyList.Items.Count.ToString());
        }
コード例 #5
0
        private static void StartMusicPlayer(PodcastItem podcastItem)
        {
            var playerPath = PodcastDownloaderConfiguration.Instance.MusicPlayer.Path;

            if (string.IsNullOrWhiteSpace(playerPath) ||
                !File.Exists(playerPath))
            {
                return;
            }

            var process = new Process
            {
                StartInfo =
                {
                    FileName         = playerPath,
                    Arguments        = string.Format("/play \"{0}\"", podcastItem.LocalPath),
                    WorkingDirectory = Path.GetDirectoryName(playerPath) ?? "."
                }
            };

            process.Start();
        }
コード例 #6
0
        public async Task UpdatePlayerProgress(int id, MediaTypes mediaType, int progess)
        {
            if (mediaType == MediaTypes.Podcast)
            {
                PodcastItem podcastItem = await dataService.Get <PodcastItem>(item => item.Id == id);

                podcastItem.Progress = progess;
                await dataService.Update(podcastItem);
            }
            else if (mediaType == MediaTypes.Song)
            {
                Track song = await dataService.Get <Track>(item => item.Id == id);

                song.Progress = progess;
                await dataService.Update(song);
            }
            else if (mediaType == MediaTypes.Television)
            {
                Episode episode = await dataService.Get <Episode>(item => item.Id == id);

                episode.Progress = progess;
                await dataService.Update(episode);
            }
        }
コード例 #7
0
        public async Task UpdatePlayCount(int id, MediaTypes mediaType)
        {
            if (mediaType == MediaTypes.Podcast)
            {
                PodcastItem podcastItem = await dataService.Get <PodcastItem>(item => item.Id == id);

                if (podcastItem != null)
                {
                    podcastItem.PlayCount++;
                    podcastItem.LastPlayedDate = DateTime.Now;
                    await dataService.Update(podcastItem);
                }
            }
            else if (mediaType == MediaTypes.Song)
            {
                Track track = await dataService.Get <Track>(item => item.Id == id);

                if (track != null)
                {
                    track.PlayCount++;
                    track.LastPlayedDate = DateTime.Now;
                    await dataService.Update(track);
                }
            }
            else if (mediaType == MediaTypes.Television)
            {
                Episode episode = await dataService.Get <Episode>(item => item.Id == id);

                if (episode != null)
                {
                    episode.PlayCount++;
                    episode.LastPlayedDate = DateTime.Now;
                    await dataService.Update(episode);
                }
            }
        }
コード例 #8
0
ファイル: Banshee.cs プロジェクト: jrudolph/do-plugins
        static IEnumerable<IMediaFile> LoadPodcastsFor(PodcastItem item)
        {
            if (item is PodcastPodcastItem) {
                yield return item as IMediaFile;
            }

            foreach (PodcastPodcastItem pc in indexer.Podcasts) {
                if ((item as PodcastPublisherItem).Name != pc.Artist) continue;

                yield return pc;
            }
        }