added play to config page
This commit is contained in:
parent
215776dce6
commit
38e5e32b42
|
@ -1,38 +1,105 @@
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.PlayTo
|
namespace MediaBrowser.Dlna.PlayTo
|
||||||
{
|
{
|
||||||
public class PlayToServerEntryPoint : IServerEntryPoint
|
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, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepo, ILibraryManager libraryManager, INetworkManager networkManager, IUserManager userManager)
|
||||||
|
|
||||||
public PlayToServerEntryPoint(ILogManager logManager, ISessionManager sessionManager, IUserManager userManager, IHttpClient httpClient, INetworkManager networkManager, IItemRepository itemRepository, ILibraryManager libraryManager)
|
|
||||||
{
|
{
|
||||||
_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()
|
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
|
#region Dispose
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (!_disposed)
|
DisposePlayToManager();
|
||||||
{
|
|
||||||
_disposed = true;
|
|
||||||
_manager.Stop();
|
|
||||||
_manager.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -80,6 +80,9 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
|
||||||
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
|
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Configuration\DlnaOptions.cs">
|
||||||
|
<Link>Configuration\DlnaOptions.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
|
||||||
<Link>Configuration\ManualLoginCategory.cs</Link>
|
<Link>Configuration\ManualLoginCategory.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\BaseApplicationConfiguration.cs">
|
||||||
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
|
<Link>Configuration\BaseApplicationConfiguration.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Configuration\DlnaOptions.cs">
|
||||||
|
<Link>Configuration\DlnaOptions.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
|
<Compile Include="..\MediaBrowser.Model\Configuration\ManualLoginCategory.cs">
|
||||||
<Link>Configuration\ManualLoginCategory.cs</Link>
|
<Link>Configuration\ManualLoginCategory.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
8
MediaBrowser.Model/Configuration/DlnaOptions.cs
Normal file
8
MediaBrowser.Model/Configuration/DlnaOptions.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
namespace MediaBrowser.Model.Configuration
|
||||||
|
{
|
||||||
|
public class DlnaOptions
|
||||||
|
{
|
||||||
|
public bool EnablePlayTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -212,6 +212,8 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public string ServerName { get; set; }
|
public string ServerName { get; set; }
|
||||||
public string WanDdns { get; set; }
|
public string WanDdns { get; set; }
|
||||||
|
|
||||||
|
public DlnaOptions DlnaOptions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -271,6 +273,8 @@ namespace MediaBrowser.Model.Configuration
|
||||||
};
|
};
|
||||||
|
|
||||||
MetadataOptions = options.ToArray();
|
MetadataOptions = options.ToArray();
|
||||||
|
|
||||||
|
DlnaOptions = new DlnaOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
<Compile Include="ApiClient\ServerEventArgs.cs" />
|
<Compile Include="ApiClient\ServerEventArgs.cs" />
|
||||||
<Compile Include="Configuration\AutoOrganize.cs" />
|
<Compile Include="Configuration\AutoOrganize.cs" />
|
||||||
<Compile Include="Configuration\BaseApplicationConfiguration.cs" />
|
<Compile Include="Configuration\BaseApplicationConfiguration.cs" />
|
||||||
|
<Compile Include="Configuration\DlnaOptions.cs" />
|
||||||
<Compile Include="Configuration\ManualLoginCategory.cs" />
|
<Compile Include="Configuration\ManualLoginCategory.cs" />
|
||||||
<Compile Include="Configuration\MetadataPlugin.cs" />
|
<Compile Include="Configuration\MetadataPlugin.cs" />
|
||||||
<Compile Include="Configuration\MetadataOptions.cs" />
|
<Compile Include="Configuration\MetadataOptions.cs" />
|
||||||
|
|
|
@ -81,7 +81,13 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||||
throw new ArgumentNullException("parentId");
|
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() ??
|
return _libraryManager.RootFolder.Children.OfType<ManualCollectionsFolder>().FirstOrDefault() ??
|
||||||
|
|
|
@ -480,6 +480,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
"dashboardinfo.js",
|
"dashboardinfo.js",
|
||||||
"dashboardpage.js",
|
"dashboardpage.js",
|
||||||
"directorybrowser.js",
|
"directorybrowser.js",
|
||||||
|
"dlnasettings.js",
|
||||||
"editcollectionitems.js",
|
"editcollectionitems.js",
|
||||||
"edititemmetadata.js",
|
"edititemmetadata.js",
|
||||||
"edititempeople.js",
|
"edititempeople.js",
|
||||||
|
|
|
@ -213,6 +213,9 @@
|
||||||
<Content Include="dashboard-ui\dashboardinfopage.html">
|
<Content Include="dashboard-ui\dashboardinfopage.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\dlnasettings.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\editcollectionitems.html">
|
<Content Include="dashboard-ui\editcollectionitems.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -483,6 +486,9 @@
|
||||||
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
|
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\scripts\dlnasettings.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\editcollectionitems.js">
|
<Content Include="dashboard-ui\scripts\editcollectionitems.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -254,4 +254,4 @@ Global
|
||||||
GlobalSection(Performance) = preSolution
|
GlobalSection(Performance) = preSolution
|
||||||
HasPerformanceSessions = true
|
HasPerformanceSessions = true
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
Loading…
Reference in New Issue
Block a user