コード例 #1
0
        /// <summary>
        /// Adds the downloaded item to a playlist in Windows Media Player.
        /// </summary>
        /// <remarks>The title of the playlist is the name of the feed in RSS Bandit.</remarks>
        /// <param name="podcast"></param>
        private void AddPodcastToWMP(DownloadItem podcast)
        {
            try
            {
                if (!IsWMPFile(Path.GetExtension(podcast.File.LocalName)))
                {
                    return;
                }

                string     playlistName = Preferences.SinglePlaylistName;
                FeedSource source       = guiMain.FeedSourceOf(podcast.OwnerFeedId);

                if (!Preferences.SinglePodcastPlaylist && source != null)
                {
                    playlistName = source.GetFeeds()[podcast.OwnerFeedId].title;
                }

                WindowsMediaPlayer wmp = new WindowsMediaPlayer();

                //get a handle to the playlist if it exists or create it if it doesn't
                IWMPPlaylist      podcastPlaylist = null;
                IWMPPlaylistArray playlists       = wmp.playlistCollection.getAll();

                for (int i = 0; i < playlists.count; i++)
                {
                    IWMPPlaylist pl = playlists.Item(i);

                    if (pl.name.Equals(playlistName))
                    {
                        podcastPlaylist = pl;
                    }
                }

                if (podcastPlaylist == null)
                {
                    podcastPlaylist = wmp.playlistCollection.newPlaylist(playlistName);
                }

                IWMPMedia wm = wmp.newMedia(Path.Combine(podcast.TargetFolder, podcast.File.LocalName));
                podcastPlaylist.appendItem(wm);
            }
            catch (Exception e)
            {
                _log.Error("The following error occured in AddPodcastToWMP(): ", e);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds the downloaded item to a playlist in iTunes.
        /// </summary>
        /// <remarks>The title of the playlist is the name of the feed in RSS Bandit.</remarks>
        /// <param name="podcast"></param>
        private void AddPodcastToITunes(DownloadItem podcast)
        {
            try
            {
                if (!IsITunesFile(Path.GetExtension(podcast.File.LocalName)))
                {
                    return;
                }

                string     playlistName = Preferences.SinglePlaylistName;
                FeedSource source       = guiMain.FeedSourceOf(podcast.OwnerFeedId);

                if (!Preferences.SinglePodcastPlaylist && source != null)
                {
                    playlistName = source.GetFeeds()[podcast.OwnerFeedId].title;
                }

                // initialize iTunes application connection
                iTunesApp itunes = new iTunesApp();

                //get a handle to the playlist if it exists or create it if it doesn't
                IITUserPlaylist podcastPlaylist = null;

                foreach (IITPlaylist pl in itunes.LibrarySource.Playlists)
                {
                    if (pl.Name.Equals(playlistName))
                    {
                        podcastPlaylist = (IITUserPlaylist)pl;
                    }
                }

                if (podcastPlaylist == null)
                {
                    podcastPlaylist = (IITUserPlaylist)itunes.CreatePlaylist(playlistName);
                }

                //add podcast to our playlist for this feed
                podcastPlaylist.AddFile(Path.Combine(podcast.TargetFolder, podcast.File.LocalName));
            }
            catch (Exception e)
            {
                _log.Error("The following error occured in AddPodcastToITunes(): ", e);
            }
        }
コード例 #3
0
 private void AssertFeedCategory(string expectedCategory, string feedUrl, FeedSource handler)
 {
     Assert.AreEqual(expectedCategory, handler.GetFeeds()[feedUrl].category);
 }
コード例 #4
0
 private void AssertFeedTitle(string expectedTitle, string feedUrl, FeedSource handler)
 {
     Assert.AreEqual(expectedTitle, handler.GetFeeds()[feedUrl].title);
 }