BrowserLauncher.cs 1.3 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 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 URL.
  30. /// </summary>
  31. /// <param name="url">The URL.</param>
  32. private static void OpenUrl(IServerApplicationHost appHost, string url)
  33. {
  34. try
  35. {
  36. appHost.LaunchUrl(url);
  37. }
  38. catch (NotSupportedException)
  39. {
  40. }
  41. catch (Exception)
  42. {
  43. }
  44. }
  45. }
  46. }