The Free Software Media System - Server Backend & API
added play to config page
Luke Pulverenti38e5e32b42a2
diff --git a/MediaBrowser.Dlna/PlayTo/PlayToServerEntryPoint.cs b/MediaBrowser.Dlna/PlayTo/PlayToServerEntryPoint.csindex b1afeb0f4a..a6746cfc50 100644--- a/MediaBrowser.Dlna/PlayTo/PlayToServerEntryPoint.cs+++ b/MediaBrowser.Dlna/PlayTo/PlayToServerEntryPoint.cs@@ -1,40 +1,107 @@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();}- #region Dispose+ void ConfigurationUpdated(object sender, EventArgs e)+ {+ ReloadPlayToManager();+ }- public void Dispose()+ 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(){- if (!_disposed)+ lock (_syncLock){- _disposed = true;- _manager.Stop();- _manager.Dispose();+ 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()+ {+ DisposePlayToManager();+ }+#endregion}}diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csprojindex 04296de355..8dd8a2a346 100644--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj@@ -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>diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csprojindex 56f7fb99d2..4cdcaae64f 100644--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj@@ -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>diff --git a/MediaBrowser.Model/Configuration/DlnaOptions.cs b/MediaBrowser.Model/Configuration/DlnaOptions.csnew file mode 100644index 0000000000..e6c24fdfb6--- /dev/null+++ b/MediaBrowser.Model/Configuration/DlnaOptions.cs@@ -0,0 +1,8 @@++namespace MediaBrowser.Model.Configuration+{+ public class DlnaOptions+ {+ public bool EnablePlayTo { get; set; }+ }+}diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex 0bff8a1bdf..c2765754e9 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -212,6 +212,8 @@ namespace MediaBrowser.Model.Configurationpublic 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();}}diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex 10aedb3baf..42ae7c396a 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -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" />diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.csindex 1cfcef5140..9a196cc47a 100644--- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs+++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs@@ -81,7 +81,13 @@ namespace MediaBrowser.Server.Implementations.Collectionsthrow 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() ??diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.csindex 19f213b2ff..fa2ae278c7 100644--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@ -480,6 +480,7 @@ namespace MediaBrowser.WebDashboard.Api"dashboardinfo.js","dashboardpage.js","directorybrowser.js",+ "dlnasettings.js","editcollectionitems.js","edititemmetadata.js","edititempeople.js",diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex 424192e283..4b2ce4833f 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -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>diff --git a/MediaBrowser.sln b/MediaBrowser.slnindex 7ac1580659..1d8a3bf265 100644--- a/MediaBrowser.sln+++ b/MediaBrowser.sln@@ -254,4 +254,4 @@ GlobalGlobalSection(Performance) = preSolutionHasPerformanceSessions = trueEndGlobalSection-EndGlobal+EndGlobal\ No newline at end of file