BrowserLauncher.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using MediaBrowser.Controller;
  2. using System;
  3. namespace MediaBrowser.Server.Startup.Common.Browser
  4. {
  5. /// <summary>
  6. /// Class BrowserLauncher
  7. /// </summary>
  8. public static class BrowserLauncher
  9. {
  10. /// <summary>
  11. /// Opens the dashboard page.
  12. /// </summary>
  13. /// <param name="page">The page.</param>
  14. /// <param name="appHost">The app host.</param>
  15. public static void OpenDashboardPage(string page, IServerApplicationHost appHost)
  16. {
  17. var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
  18. OpenUrl(appHost, url);
  19. }
  20. /// <summary>
  21. /// Opens the community.
  22. /// </summary>
  23. public static void OpenCommunity(IServerApplicationHost appHost)
  24. {
  25. OpenUrl(appHost, "http://emby.media/community");
  26. }
  27. /// <summary>
  28. /// Opens the web client.
  29. /// </summary>
  30. /// <param name="appHost">The app host.</param>
  31. public static void OpenWebClient(IServerApplicationHost appHost)
  32. {
  33. OpenDashboardPage("index.html", appHost);
  34. }
  35. /// <summary>
  36. /// Opens the dashboard.
  37. /// </summary>
  38. /// <param name="appHost">The app host.</param>
  39. public static void OpenDashboard(IServerApplicationHost appHost)
  40. {
  41. OpenDashboardPage("dashboard.html", appHost);
  42. }
  43. /// <summary>
  44. /// Opens the URL.
  45. /// </summary>
  46. /// <param name="url">The URL.</param>
  47. private static void OpenUrl(IServerApplicationHost appHost, string url)
  48. {
  49. try
  50. {
  51. appHost.LaunchUrl(url);
  52. }
  53. catch (NotImplementedException)
  54. {
  55. }
  56. catch (Exception ex)
  57. {
  58. Console.WriteLine("Error launching url: " + url);
  59. Console.WriteLine(ex.Message);
  60. }
  61. }
  62. }
  63. }