BrowserLauncher.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using MediaBrowser.Controller;
  3. namespace Emby.Server.Implementations.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. private 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 web client.
  22. /// </summary>
  23. /// <param name="appHost">The app host.</param>
  24. public static void OpenWebApp(IServerApplicationHost appHost)
  25. {
  26. OpenDashboardPage("index.html", appHost);
  27. }
  28. /// <summary>
  29. /// Opens the swagger API page.
  30. /// </summary>
  31. /// <param name="appHost">The app host.</param>
  32. public static void OpenSwaggerPage(IServerApplicationHost appHost)
  33. {
  34. var url = appHost.GetLocalApiUrl("localhost") + "/swagger/index.html";
  35. OpenUrl(appHost, url);
  36. }
  37. /// <summary>
  38. /// Opens the URL.
  39. /// </summary>
  40. /// <param name="appHost">The application host instance.</param>
  41. /// <param name="url">The URL.</param>
  42. private static void OpenUrl(IServerApplicationHost appHost, string url)
  43. {
  44. try
  45. {
  46. appHost.LaunchUrl(url);
  47. }
  48. catch (NotSupportedException)
  49. {
  50. }
  51. catch (Exception)
  52. {
  53. }
  54. }
  55. }
  56. }