added play to config page

This commit is contained in:
Luke Pulverenti 2014-03-10 13:38:53 -04:00
parent 215776dce6
commit 38e5e32b42
10 changed files with 113 additions and 14 deletions

View File

@ -1,38 +1,105 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.Dlna.PlayTo
{
public class PlayToServerEntryPoint : IServerEntryPoint
{
private bool _disposed;
private PlayToManager _manager;
private readonly IServerConfigurationManager _config;
private readonly ILogger _logger;
private readonly ISessionManager _sessionManager;
private readonly IHttpClient _httpClient;
private readonly IItemRepository _itemRepo;
private readonly ILibraryManager _libraryManager;
private readonly INetworkManager _networkManager;
private readonly IUserManager _userManager;
private readonly PlayToManager _manager;
public PlayToServerEntryPoint(ILogManager logManager, ISessionManager sessionManager, IUserManager userManager, IHttpClient httpClient, INetworkManager networkManager, IItemRepository itemRepository, ILibraryManager libraryManager)
public PlayToServerEntryPoint(ILogManager logManager, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepo, ILibraryManager libraryManager, INetworkManager networkManager, IUserManager userManager)
{
_manager = new PlayToManager(logManager.GetLogger("PlayTo"), sessionManager, httpClient, itemRepository, libraryManager, networkManager, userManager);
_config = config;
_sessionManager = sessionManager;
_httpClient = httpClient;
_itemRepo = itemRepo;
_libraryManager = libraryManager;
_networkManager = networkManager;
_userManager = userManager;
_logger = logManager.GetLogger("PlayTo");
}
public void Run()
{
//_manager.Start();
_config.ConfigurationUpdated += ConfigurationUpdated;
ReloadPlayToManager();
}
void ConfigurationUpdated(object sender, EventArgs e)
{
ReloadPlayToManager();
}
private void ReloadPlayToManager()
{
var isStarted = _manager != null;
if (_config.Configuration.DlnaOptions.EnablePlayTo && !isStarted)
{
StartPlayToManager();
}
else if (!_config.Configuration.DlnaOptions.EnablePlayTo && isStarted)
{
DisposePlayToManager();
}
}
private readonly object _syncLock = new object();
private void StartPlayToManager()
{
lock (_syncLock)
{
try
{
_manager = new PlayToManager(_logger, _sessionManager, _httpClient, _itemRepo, _libraryManager, _networkManager, _userManager);
_manager.Start();
}
catch (Exception ex)
{
_logger.ErrorException("Error starting PlayTo manager", ex);
}
}
}
private void DisposePlayToManager()
{
lock (_syncLock)
{
if (_manager != null)
{
try
{
_manager.Stop();
_manager.Dispose();
}
catch (Exception ex)
{
_logger.ErrorException("Error disposing PlayTo manager", ex);
}
_manager = null;
}
}
}
#region Dispose
public void Dispose()
{
if (!_disposed)
{
_disposed = true;
_manager.Stop();
_manager.Dispose();
}
DisposePlayToManager();
}
#endregion

View File

@ -80,6 +80,9 @@
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Configuration\DlnaOptions.cs">
<Link>Configuration\DlnaOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
<Link>Configuration\ManualLoginCategory.cs</Link>
</Compile>

View File

@ -67,6 +67,9 @@
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Configuration\DlnaOptions.cs">
<Link>Configuration\DlnaOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
<Link>Configuration\ManualLoginCategory.cs</Link>
</Compile>

View File

@ -0,0 +1,8 @@

namespace MediaBrowser.Model.Configuration
{
public class DlnaOptions
{
public bool EnablePlayTo { get; set; }
}
}

View File

@ -212,6 +212,8 @@ namespace MediaBrowser.Model.Configuration
public string ServerName { get; set; }
public string WanDdns { get; set; }
public DlnaOptions DlnaOptions { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary>
@ -271,6 +273,8 @@ namespace MediaBrowser.Model.Configuration
};
MetadataOptions = options.ToArray();
DlnaOptions = new DlnaOptions();
}
}

View File

@ -60,6 +60,7 @@
<Compile Include="ApiClient\ServerEventArgs.cs" />
<Compile Include="Configuration\AutoOrganize.cs" />
<Compile Include="Configuration\BaseApplicationConfiguration.cs" />
<Compile Include="Configuration\DlnaOptions.cs" />
<Compile Include="Configuration\ManualLoginCategory.cs" />
<Compile Include="Configuration\MetadataPlugin.cs" />
<Compile Include="Configuration\MetadataOptions.cs" />

View File

@ -81,7 +81,13 @@ namespace MediaBrowser.Server.Implementations.Collections
throw new ArgumentNullException("parentId");
}
return _libraryManager.GetItemById(parentId.Value) as Folder;
var folder = _libraryManager.GetItemById(parentId.Value) as Folder;
// Find an actual physical folder
if (folder is CollectionFolder)
{
return _libraryManager.RootFolder.Children.OfType<Folder>().First(i => folder.PhysicalLocations.Contains(i.Path, StringComparer.OrdinalIgnoreCase));
}
}
return _libraryManager.RootFolder.Children.OfType<ManualCollectionsFolder>().FirstOrDefault() ??

View File

@ -480,6 +480,7 @@ namespace MediaBrowser.WebDashboard.Api
"dashboardinfo.js",
"dashboardpage.js",
"directorybrowser.js",
"dlnasettings.js",
"editcollectionitems.js",
"edititemmetadata.js",
"edititempeople.js",

View File

@ -213,6 +213,9 @@
<Content Include="dashboard-ui\dashboardinfopage.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\dlnasettings.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\editcollectionitems.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -483,6 +486,9 @@
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\dlnasettings.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\editcollectionitems.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -254,4 +254,4 @@ Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal
EndGlobal