public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: if (newDllsDownloaded) { newDllsDownloaded = false; ReloadDownloadedDlls(); PluginConfiguration.Instance.BuildAutomaticSitesGroups(); } else if (newDataSaved) { newDataSaved = false; OnlineVideoSettings.Instance.BuildSiteUtilsList(); PluginConfiguration.Instance.BuildAutomaticSitesGroups(); // reset the GuiOnlineVideos instance GUIOnlineVideos ovGuiInstance = (GUIOnlineVideos)GUIWindowManager.GetWindow(GUIOnlineVideos.WindowId); if (ovGuiInstance != null) { ovGuiInstance.ResetToFirstView(); } } break; } return(base.OnMessage(message)); }
internal static void ReloadDownloadedDlls() { Log.Instance.Info("Reloading SiteUtil Dlls at runtime."); bool stopPlayback = (MediaPortal.Player.g_Player.Player != null && MediaPortal.Player.g_Player.Player.GetType().Assembly == typeof(GUISiteUpdater).Assembly); bool stopDownload = DownloadManager.Instance.Count > 0; if (stopDownload || stopPlayback) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.NewDllDownloaded); int i = 1; if (stopDownload) { dlg.SetLine(i++, Translation.Instance.DownloadsWillBeAborted); } if (stopPlayback) { dlg.SetLine(i++, Translation.Instance.PlaybackWillBeStopped); } dlg.DoModal(GUIWindowManager.ActiveWindow); } } // stop playback if an OnlineVideos video is playing if (stopPlayback) { MediaPortal.Player.g_Player.Stop(); } // stop downloads DownloadManager.Instance.StopAll(); // reset the GuiOnlineVideos instance and stop the LatestVideos Thread GUIOnlineVideos ovGuiInstance = (GUIOnlineVideos)GUIWindowManager.GetWindow(GUIOnlineVideos.WindowId); if (ovGuiInstance != null) { ovGuiInstance.ResetToFirstView(); ovGuiInstance.LatestVideosManager.Stop(); } // now reload the appdomain OnlineVideoSettings.Reload(); TranslationLoader.SetTranslationsToSingleton(); OnlineVideoSettings.Instance.BuildSiteUtilsList(); GC.Collect(); GC.WaitForFullGCComplete(); // restart the LatestVideos thread ovGuiInstance.LatestVideosManager.Start(); }