BrowserLauncher.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 web client.
  12. /// </summary>
  13. /// <param name="appHost">The app host.</param>
  14. public static void OpenWebApp(IServerApplicationHost appHost)
  15. {
  16. var url = appHost.GetLocalApiUrl("localhost") + "/web/index.html";
  17. OpenUrl(appHost, url);
  18. }
  19. /// <summary>
  20. /// Opens the swagger API page.
  21. /// </summary>
  22. /// <param name="appHost">The app host.</param>
  23. public static void OpenSwaggerPage(IServerApplicationHost appHost)
  24. {
  25. var url = appHost.GetLocalApiUrl("localhost") + "/swagger/index.html";
  26. OpenUrl(appHost, url);
  27. }
  28. /// <summary>
  29. /// Opens the URL.
  30. /// </summary>
  31. /// <param name="appHost">The application host instance.</param>
  32. /// <param name="url">The URL.</param>
  33. private static void OpenUrl(IServerApplicationHost appHost, string url)
  34. {
  35. try
  36. {
  37. appHost.LaunchUrl(url);
  38. }
  39. catch (NotSupportedException)
  40. {
  41. }
  42. catch (Exception)
  43. {
  44. }
  45. }
  46. }
  47. }