2
0

BrowserLauncher.cs 2.0 KB

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