BrowserLauncher.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using MediaBrowser.Controller;
  2. using System;
  3. namespace Emby.Server.Core.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. public static void OpenEmbyPremiere(IServerApplicationHost appHost)
  28. {
  29. OpenDashboardPage("supporterkey.html", appHost);
  30. }
  31. /// <summary>
  32. /// Opens the web client.
  33. /// </summary>
  34. /// <param name="appHost">The app host.</param>
  35. public static void OpenWebClient(IServerApplicationHost appHost)
  36. {
  37. OpenDashboardPage("index.html", appHost);
  38. }
  39. /// <summary>
  40. /// Opens the dashboard.
  41. /// </summary>
  42. /// <param name="appHost">The app host.</param>
  43. public static void OpenDashboard(IServerApplicationHost appHost)
  44. {
  45. OpenDashboardPage("dashboard.html", appHost);
  46. }
  47. /// <summary>
  48. /// Opens the URL.
  49. /// </summary>
  50. /// <param name="url">The URL.</param>
  51. private static void OpenUrl(IServerApplicationHost appHost, string url)
  52. {
  53. try
  54. {
  55. appHost.LaunchUrl(url);
  56. }
  57. catch (NotImplementedException)
  58. {
  59. }
  60. catch (Exception ex)
  61. {
  62. Console.WriteLine("Error launching url: " + url);
  63. Console.WriteLine(ex.Message);
  64. }
  65. }
  66. }
  67. }