using System;
using MediaBrowser.Controller;
namespace Emby.Server.Implementations.Browser
{
    /// 
    /// Class BrowserLauncher.
    /// 
    public static class BrowserLauncher
    {
        /// 
        /// Opens the dashboard page.
        /// 
        /// The page.
        /// The app host.
        private static void OpenDashboardPage(string page, IServerApplicationHost appHost)
        {
            var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
            OpenUrl(appHost, url);
        }
        /// 
        /// Opens the web client.
        /// 
        /// The app host.
        public static void OpenWebApp(IServerApplicationHost appHost)
        {
            OpenDashboardPage("index.html", appHost);
        }
        /// 
        /// Opens the URL.
        /// 
        /// The application host instance.
        /// The URL.
        private static void OpenUrl(IServerApplicationHost appHost, string url)
        {
            try
            {
                appHost.LaunchUrl(url);
            }
            catch (NotSupportedException)
            {
            }
            catch (Exception)
            {
            }
        }
    }
}