BrowserLauncher.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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="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. }