aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Browser/BrowserLauncher.cs
blob: 752650ae18dcb7824c69c78f74adedafa50f7bd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using MediaBrowser.Controller;

namespace Emby.Server.Implementations.Browser
{
    /// <summary>
    /// Class BrowserLauncher.
    /// </summary>
    public static class BrowserLauncher
    {
        /// <summary>
        /// Opens the web client.
        /// </summary>
        /// <param name="appHost">The app host.</param>
        public static void OpenWebApp(IServerApplicationHost appHost)
        {
            var url = appHost.GetLocalApiUrl("localhost") + "/web/index.html";
            OpenUrl(appHost, url);
        }

        /// <summary>
        /// Opens the swagger API page.
        /// </summary>
        /// <param name="appHost">The app host.</param>
        public static void OpenSwaggerPage(IServerApplicationHost appHost)
        {
            var url = appHost.GetLocalApiUrl("localhost") + "/swagger/index.html";
            OpenUrl(appHost, url);
        }

        /// <summary>
        /// Opens the URL.
        /// </summary>
        /// <param name="appHost">The application host instance.</param>
        /// <param name="url">The URL.</param>
        private static void OpenUrl(IServerApplicationHost appHost, string url)
        {
            try
            {
                appHost.LaunchUrl(url);
            }
            catch (NotSupportedException)
            {

            }
            catch (Exception)
            {
            }
        }
    }
}