Beispiel #1
0
        /// <summary>
        /// End Point (Clean up)
        /// </summary>
        public override void DeInit()
        {
            FileLog.Debug("Removing Mediaportal Hooks");
            GUIWindowManager.OnDeActivateWindow -= GUIWindowManager_OnDeActivateWindow;
            GUIWindowManager.OnActivateWindow   -= GUIWindowManager_OnActivateWindow;
            GUIWindowManager.Receivers          -= GUIWindowManager_Receivers;

            // UnLoad Trailer Providers
            UnLoadTrailerProviders();

            // save settings
            PluginSettings.SaveSettings();

            FileLog.Info("Goodbye");
            base.DeInit();
        }
Beispiel #2
0
        /// <summary>
        /// Get OnlineVideos download directories for possible source of Trailers
        /// </summary>
        static string GetOnlineVideosDownloadDirs()
        {
            string trailerDirs = string.Empty;
            string downloadDir = string.Empty;

            FileLog.Debug("Getting DownloadDir from OnlineVideos");
            using (Settings xmlreader = new MPSettings())
            {
                downloadDir = xmlreader.GetValueAsString(cOnlineVideos, cOnlineVideosDownloadDir, string.Empty);
            }

            if (!string.IsNullOrEmpty(downloadDir))
            {
                // add iTunes, IMDb and YouTube as possible trailer directories
                trailerDirs  = string.Format("{0}", Path.Combine(downloadDir, "YouTube"));
                trailerDirs += string.Format("|{0}", Path.Combine(downloadDir, "iTunes Movie Trailers"));
                trailerDirs += string.Format("|{0}", Path.Combine(downloadDir, "IMDb Movie Trailers"));
            }

            return(trailerDirs);
        }
Beispiel #3
0
        /// <summary>
        /// Get ShowTimes Trailer download directory
        /// </summary>
        /// <returns></returns>
        static string GetShowTimesTrailerDir()
        {
            string showTimesConfigFile = string.Empty;
            string trailerDir          = string.Empty;

            FileLog.Debug("Getting ShowTimes Config location");

            using (Settings xmlreader = new MPSettings())
            {
                showTimesConfigFile = xmlreader.GetValueAsString(cShowTimes, cShowTimesConfigFile, string.Empty);
            }

            if (!string.IsNullOrEmpty(showTimesConfigFile))
            {
                FileLog.Debug("Getting ShowTimes Trailer folder");

                try
                {
                    if (File.Exists(showTimesConfigFile))
                    {
                        var xmlDoc = new XmlDocument();
                        xmlDoc.Load(showTimesConfigFile);

                        var node = xmlDoc.SelectSingleNode("/ConfigurationSettings/TrailerFolder");
                        if (node != null)
                        {
                            trailerDir = node.InnerText;
                        }
                    }
                }
                catch (Exception e)
                {
                    FileLog.Error("Unable to get trailer directory for ShowTimes plugin!: {0}", e.Message);
                }
            }

            return(trailerDir);
        }
Beispiel #4
0
        public static void SearchForTrailers(MediaItem searchItem)
        {
            ReShowTrailerMenu = false;

            GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() =>
            {
                var menuItems = new List <GUITrailerListItem>();

                // add enabled local sources
                foreach (var trailerProvider in TrailerProviders.Where(t => t.IsLocal && t.Enabled))
                {
                    menuItems.AddRange(trailerProvider.Search(searchItem));
                }

                // add enabled online sources
                if (menuItems.Count == 0 || !PluginSettings.SkipOnlineProvidersIfLocalFound)
                {
                    foreach (var trailerProvider in TrailerProviders.Where(t => !t.IsLocal && t.Enabled))
                    {
                        menuItems.AddRange(trailerProvider.Search(searchItem));
                    }
                }

                return(menuItems);
            },
                                                                      delegate(bool success, object result)
            {
                if (success)
                {
                    FileLog.Debug("Showing Trailer Menu for selection.");
                    var menuItems = result as List <GUITrailerListItem>;
                    if (menuItems.Count > 0)
                    {
                        #region Auto-Play
                        // only one local trailer
                        if (PluginSettings.AutoPlayOnSingleLocalOrOnlineTrailer && menuItems.Where(t => !t.IsOnlineItem && !t.IsSearchItem).Count() == 1)
                        {
                            var localTrailer = menuItems.Find(t => !t.IsOnlineItem);
                            LocalPlayer.Play(localTrailer.URL, localTrailer.CurrentMedia);
                            return;
                        }
                        // only one online trailer
                        else if (PluginSettings.AutoPlayOnSingleLocalOrOnlineTrailer && menuItems.Where(t => t.IsOnlineItem && !t.IsSearchItem).Count() == 1)
                        {
                            var onlineTrailer = menuItems.Find(t => t.IsOnlineItem && !t.IsSearchItem);
                            OnlinePlayer.Play(onlineTrailer.URL, onlineTrailer.CurrentMedia);
                            return;
                        }
                        // only one of anything - doesn't matter if AutoPlay is enabled just do it.
                        else if (menuItems.Count == 1)
                        {
                            FileLog.Info("Only a single result to show, skipping GUI menu selection dialog.");

                            if (menuItems.First().IsSearchItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems.First().URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems.First().URL);
                            }
                            else if (menuItems.First().IsOnlineItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems.First().URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems.First().URL);
                            }
                            else
                            {
                                LocalPlayer.Play(menuItems.First().URL, menuItems.First().CurrentMedia);
                            }
                            return;
                        }
                        #endregion

                        #region Show Menu
                        int selectedItem = GUIUtils.ShowMenuDialog(menuItems.First().CurrentMedia.ToString(), menuItems);
                        if (selectedItem >= 0)
                        {
                            // re-show menu after playback is enabled and there is more than one local/online trailer to select.
                            ReShowTrailerMenu = PluginSettings.ReShowMenuAfterTrailerPlay && (menuItems.Count(t => !t.IsSearchItem) > 1);
                            CurrentMediaItem  = menuItems[selectedItem].CurrentMedia;

                            // Search or Play?
                            if (menuItems[selectedItem].IsSearchItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems[selectedItem].URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems[selectedItem].URL);
                            }
                            else if (menuItems[selectedItem].IsOnlineItem)
                            {
                                // play the selected trailer
                                OnlinePlayer.Play(menuItems[selectedItem].URL, menuItems[selectedItem].CurrentMedia);
                            }
                            else
                            {
                                // play local media
                                LocalPlayer.Play(menuItems[selectedItem].URL, menuItems[selectedItem].CurrentMedia);
                            }
                        }
                        else
                        {
                            FileLog.Debug("No Trailer selected for playback or search.");
                        }
                        #endregion
                    }
                    else
                    {
                        GUIUtils.ShowNotifyDialog(Translation.Trailers, Translation.NoTrailersFound);
                    }
                }
            }, Translation.GettingTrailers, true);
        }