2013-09-24 20:54:51 -04:00
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
2014-11-09 13:24:57 -05:00
|
|
|
|
namespace MediaBrowser.Server.Startup.Common.Browser
|
2013-09-24 20:54:51 -04:00
|
|
|
|
{
|
2013-09-27 13:04:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class BrowserLauncher
|
|
|
|
|
/// </summary>
|
2013-09-24 20:54:51 -04:00
|
|
|
|
public static class BrowserLauncher
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Opens the dashboard page.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="page">The page.</param>
|
|
|
|
|
/// <param name="appHost">The app host.</param>
|
2013-09-27 13:04:35 -04:00
|
|
|
|
/// <param name="logger">The logger.</param>
|
2014-11-02 22:38:43 -05:00
|
|
|
|
public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger)
|
2013-09-24 20:54:51 -04:00
|
|
|
|
{
|
2015-02-10 00:54:58 -05:00
|
|
|
|
var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
|
2013-09-24 20:54:51 -04:00
|
|
|
|
|
|
|
|
|
OpenUrl(url, logger);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 13:04:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Opens the community.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
|
|
|
|
public static void OpenCommunity(ILogger logger)
|
|
|
|
|
{
|
2015-03-21 14:12:12 -04:00
|
|
|
|
OpenUrl("http://emby.media/community", logger);
|
2013-09-27 13:04:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Opens the web client.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="appHost">The app host.</param>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2014-11-02 22:38:43 -05:00
|
|
|
|
public static void OpenWebClient(IServerApplicationHost appHost, ILogger logger)
|
2013-09-27 13:04:35 -04:00
|
|
|
|
{
|
2014-11-02 22:38:43 -05:00
|
|
|
|
OpenDashboardPage("index.html", appHost, logger);
|
2013-09-27 13:04:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Opens the dashboard.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="appHost">The app host.</param>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2014-11-02 22:38:43 -05:00
|
|
|
|
public static void OpenDashboard(IServerApplicationHost appHost, ILogger logger)
|
2013-09-27 13:04:35 -04:00
|
|
|
|
{
|
2016-03-16 14:09:58 -04:00
|
|
|
|
OpenDashboardPage("dashboard.html", appHost, logger);
|
2013-09-27 13:04:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-24 20:54:51 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Opens the URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url">The URL.</param>
|
2013-09-27 13:04:35 -04:00
|
|
|
|
/// <param name="logger">The logger.</param>
|
|
|
|
|
private static void OpenUrl(string url, ILogger logger)
|
2013-09-24 20:54:51 -04:00
|
|
|
|
{
|
|
|
|
|
var process = new Process
|
2013-12-05 11:50:21 -05:00
|
|
|
|
{
|
|
|
|
|
StartInfo = new ProcessStartInfo
|
2013-09-24 20:54:51 -04:00
|
|
|
|
{
|
2013-12-05 11:50:21 -05:00
|
|
|
|
FileName = url
|
|
|
|
|
},
|
2013-09-24 20:54:51 -04:00
|
|
|
|
|
2013-12-05 11:50:21 -05:00
|
|
|
|
EnableRaisingEvents = true,
|
|
|
|
|
};
|
2013-09-24 20:54:51 -04:00
|
|
|
|
|
|
|
|
|
process.Exited += ProcessExited;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
process.Start();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.ErrorException("Error launching url: {0}", ex, url);
|
|
|
|
|
|
2015-02-10 00:54:58 -05:00
|
|
|
|
Console.WriteLine("Error launching url: {0}", ex.Message);
|
2013-12-05 11:50:21 -05:00
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
|
2014-10-06 19:58:46 -04:00
|
|
|
|
//#if !__MonoCS__
|
|
|
|
|
// System.Windows.Forms.MessageBox.Show("There was an error launching your web browser. Please check your default browser settings.");
|
|
|
|
|
//#endif
|
2013-09-24 20:54:51 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Processes the exited.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
|
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
|
|
|
private static void ProcessExited(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
((Process)sender).Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|