public static void AddGroupHeaders(MovieBrowser browser)
        {
            Browser = browser;
            for (int i = Browser.Facade.Count - 1; i >= 0; i--) {
                string priorGroupName = "";
                string thisGroupName = "";

                DBMovieInfo thisMovie = ((DBMovieInfo)Browser.Facade[i].TVTag);
                thisGroupName = DetermineGroupName(thisMovie);

                if (i > 0) {
                    DBMovieInfo priorMovie = ((DBMovieInfo)Browser.Facade[i - 1].TVTag);
                    priorGroupName = DetermineGroupName(priorMovie);
                }
                else {
                    priorGroupName = "";
                }

                if (priorGroupName != thisGroupName) {
                    // if this movie's group differs from the prior, insert a group header
                    try { InsertGroupHeader(i, thisGroupName); }
                    catch (TypeLoadException) {
                        logger.Warn("Grouping headers are not supported with this version of MediaPortal!");
                    }
                }
            }
        }
        // retrieves info from Moving Pictures
        protected override bool GrabFileDetails()
        {
            try {
                browser = MovingPicturesCore.Browser;
                selectedMovie = browser.SelectedMovie;
                List<DBLocalMedia> localMedia = selectedMovie.LocalMedia;

                _mediaDetail = new BasicMediaDetail();

                _mediaDetail.Title = selectedMovie.Title;
                _mediaDetail.Year = selectedMovie.Year;
                _mediaDetail.ImdbID = selectedMovie.ImdbID;

                _mediaDetail.Thumb = selectedMovie.CoverThumbFullPath;
                _mediaDetail.FanArt = selectedMovie.BackdropFullPath;
                _mediaDetail.Files = new List<FileInfo>();
                foreach (DBLocalMedia localMediaItem in localMedia) {
                    _mediaDetail.Files.Add(new FileInfo(localMediaItem.FullPath));
                }

                return true;
            }
            catch (Exception e) {
                logger.ErrorException(string.Format("Unexpected error when pulling data from Moving Pictures{0}", Environment.NewLine), e);
                return false;
            }
        }
        public static bool GetCurrentMediaItem(out MediaItem currentMediaItem, out bool isDetailsView)
        {
            FileLog.Info("Getting selected movie information from MovingPictures.");

            currentMediaItem = new MediaItem();
            browser = MovingPicturesCore.Browser;
            isDetailsView = browser.CurrentView.ToString().Equals("DETAILS");

            selectedMovie = browser.SelectedMovie;

            currentMediaItem.Title = selectedMovie.Title;
            currentMediaItem.Year = selectedMovie.Year;
            currentMediaItem.Plot = selectedMovie.Summary;
            currentMediaItem.Poster = selectedMovie.CoverFullPath;

            // Get local file information
            currentMediaItem.FullPath = selectedMovie.LocalMedia.First().FullPath;

            // Check if TMDb ID is available
            string tmdbid = GetTmdbID(selectedMovie);
            if (!string.IsNullOrEmpty(tmdbid)) currentMediaItem.TMDb = tmdbid;

            // Next best ID to use
            string imdbid = selectedMovie.ImdbID;
            if (!string.IsNullOrEmpty(imdbid) && imdbid.Length == 9) currentMediaItem.IMDb = imdbid;

            return true;
        }
        protected override void OnPageLoad()
        {
            logger.Debug("OnPageLoad() Started.");

            // if the component didn't load properly we probably have a bad skin file
            if (facade == null) {
                // avoid showing a dialog on load when we are the last active module being started
                if (!preventDialogOnLoad) {
                    GUIDialogOK dialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                    dialog.Reset();
                    dialog.SetHeading(Translation.Error);
                    dialog.SetLine(1, Translation.ProblemLoadingSkinFile);
                    dialog.DoModal(GetID);
                }
                else {
                    preventDialogOnLoad = false;
                }
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // Check whether the plugin is initialized.
            if (!initComplete) {

                // avoid showing a dialog on load when we are the last active module being started
                if (preventDialogOnLoad) {
                    preventDialogOnLoad = false;
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }

                // if we are not initialized yet show a loading dialog
                // this will 'block' untill loading has finished or the user
                // pressed cancel or ESC
                showLoadingDialog();

                // if the initialization is not complete the user cancelled
                if (!initComplete) {
                    // return to where the user came from
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
            }

            // notify if the skin doesnt support categories
            if (categoriesFacade == null && MovingPicturesCore.Settings.CategoriesEnabled) {
                // avoid showing a dialog on load when we are the last active module being started
                if (!preventDialogOnLoad) {
                    GUIDialogOK dialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                    dialog.Reset();
                    dialog.SetHeading(Translation.Error);
                    dialog.SetLine(1, "This skin does not support Categories...");
                    dialog.DoModal(GetID);
                }
                else {
                    preventDialogOnLoad = false;
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
            }

            // if the user hasn't defined any import paths they need to goto the config screen
            if (DBImportPath.GetAllUserDefined().Count == 0) {
                GUIWindowManager.ShowPreviousWindow();
                if (!preventDialogOnLoad) {
                    ShowMessage(Translation.NoImportPathsHeading, Translation.NoImportPathsBody);
                }
                else {
                    preventDialogOnLoad = false;
                }
                return;
            }

            // if we were passed a parameter we cant parse, exit back
            if (MovieLoadParamater == null && CategoryLoadParamater == null && SearchModeLoadParameter == null && !string.IsNullOrEmpty(UnparsedLoadParameter)) {
                logger.Warn("Moving Pictures can not understand the following paramater: " + UnparsedLoadParameter);
                GUIWindowManager.ShowPreviousWindow();
                ShowMessage(Translation.Error, Translation.BadParam);
            }

            if (browser == null) {
                browser = new MovieBrowser(skinSettings);
                MovingPicturesCore.Browser = browser;

                // add available filters to browser
                remoteFilter = new RemoteNumpadFilter();
                browser.Filters.Add(remoteFilter);

                parentalControlsFilter = MovingPicturesCore.Settings.ParentalControlsFilter;
                parentalControlsFilter.Active = MovingPicturesCore.Settings.ParentalControlsEnabled;
                browser.Filters.Add(parentalControlsFilter);

                // setup browser events
                browser.MovieSelectionChanged += new MovieBrowser.MovieSelectionChangedDelegate(MovieDetailsPublisher);
                browser.NodeSelectionChanged += new MovieBrowser.NodeSelectionChangedDelegate(PublishCategoryDetails);
                browser.ContentsChanged += new MovieBrowser.ContentsChangedDelegate(OnBrowserContentsChanged);
                browser.ViewChanged += new MovieBrowser.ViewChangedDelegate(OnBrowserViewChanged);

                // Load all available translation strings
                foreach (string name in Translation.Strings.Keys) {
                    SetProperty("#MovingPictures.Translation." + name + ".Label", Translation.Strings[name]);
                }

                SetProperty("#MovingPictures.Sort.Field", Sort.GetFriendlySortName(browser.CurrentSortField));
                SetProperty("#MovingPictures.Sort.Direction", browser.CurrentSortDirection.ToString());

                // if enabled, activate the default filter
                if (MovingPicturesCore.Settings.DefaultFilterEnabled)
                    browser.FilterNode = MovingPicturesCore.Settings.DefaultFilter;

                if (filteringIndicator != null) filteringIndicator.Visible = false;

                PublishFilterDetails();
            }

            if (recentInsertedDiskSerials == null) {
                // Also listen to new movies added as part of the autoplay/details functionality
                if (diskInsertedAction != DiskInsertedAction.NOTHING) {
                    recentInsertedDiskSerials = new Dictionary<string, string>();
                    MovingPicturesCore.DatabaseManager.ObjectInserted += new DatabaseManager.ObjectAffectedDelegate(OnMovieAdded);
                    logger.Debug("Autoplay/details is now listening for movie additions");
                }
            }

            // (re)link our backdrop image controls to the backdrop image swapper
            backdrop.GUIImageOne = movieBackdropControl;
            backdrop.GUIImageTwo = movieBackdropControl2;
            backdrop.LoadingImage = loadingImage;

            // (re)link the facade controls to the browser object
            browser.Facade = facade;
            browser.CategoriesFacade = categoriesFacade;

            // we are supposed to launch on a movie page, pass this to movie browser
            if (MovieLoadParamater != null) {
                browser.RememberLastState = false;

                browser.SelectedMovie = MovieLoadParamater;
                browser.CurrentView = BrowserViewMode.DETAILS;
                browser.TopLevelView = BrowserViewMode.DETAILS;
            }

            // we are supposed to launch on a category page, pass this to movie browser
            else if (CategoryLoadParamater != null && browser.CategoriesAvailable) {
                browser.RememberLastState = true;

                browser.TopLevelNode = CategoryLoadParamater;
                browser.CurrentNode = CategoryLoadParamater;

                if (CategoryLoadParamater.HasChildren) {
                    browser.TopLevelView = BrowserViewMode.CATEGORIES;
                    browser.CurrentView = BrowserViewMode.CATEGORIES;
                }
                else {
                    browser.TopLevelView = MovingPicturesCore.Settings.DefaultView;
                    browser.CurrentView = MovingPicturesCore.Settings.DefaultView;
                }

                loaded = true;
                preventDialogOnLoad = false;

            }

            else if (SearchStringLoadParameter != null && SearchModeLoadParameter != null) {
                bool success = Search((SearchMode)SearchModeLoadParameter, SearchStringLoadParameter);
                if (!success) {
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }

                browser.TopLevelView = browser.CurrentView;
            }

            // standard loading logic
            else {
                if (browser.CategoriesAvailable || browser.LastView != BrowserViewMode.CATEGORIES) {
                    browser.TopLevelView = BrowserViewMode.CATEGORIES;
                    browser.TopLevelNode = null;
                    browser.RememberLastState = true;

                    if (browser.LastView == BrowserViewMode.DETAILS) {
                        browser.SelectedMovie = browser.LastSelectedMovie;
                        browser.CurrentView = BrowserViewMode.DETAILS;
                    }
                    else {
                        browser.SelectedMovie = browser.LastSelectedMovie;
                        browser.CurrentNode = browser.LastNode;
                        browser.CurrentView = browser.LastView;
                    }
                }
                else {
                    //the skin doesn't support categories
                    browser.CurrentNode = null;
                    browser.CurrentView = MovingPicturesCore.Settings.DefaultView;
                }
            }

            MediaPortal.GUI.Library.GUIPropertyManager.SetProperty("#currentmodule", MovingPicturesCore.Settings.HomeScreenName);
            browser.AutoRefresh = true;

            setWorkingAnimationStatus(false);
            if (movieStartIndicator != null)
                movieStartIndicator.Visible = false;

            // Take control and disable MediaPortal AutoPlay when the plugin has focus
            disableNativeAutoplay();

            if (awaitingUserRatingMovie != null) {
                GetUserRating(awaitingUserRatingMovie);
                awaitingUserRatingMovie = null;
            }

            logger.Debug("OnPageLoad() Ended.");
        }