diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-12 18:30:32 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-12 18:30:32 -0400 |
| commit | d4d10f6e433cc472c5aafe6af53a101bba36bf79 (patch) | |
| tree | 9426472a3ae99e09813f264fc0a464d9c11ce895 | |
| parent | bf0e9d36a909856506f522ba4e3cbf97248f0f1a (diff) | |
add new subtitle preferences
16 files changed, 30 insertions, 354 deletions
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index 82b6229a1..e688973f9 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -16,13 +16,6 @@ namespace MediaBrowser.Api [Route("/Sessions", "GET", Summary = "Gets a list of sessions")] public class GetSessions : IReturn<List<SessionInfoDto>> { - /// <summary> - /// Gets or sets a value indicating whether [supports remote control]. - /// </summary> - /// <value><c>null</c> if [supports remote control] contains no value, <c>true</c> if [supports remote control]; otherwise, <c>false</c>.</value> - [ApiMember(Name = "SupportsRemoteControl", Description = "Optional. Filter by sessions that can be remote controlled.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] - public bool? SupportsRemoteControl { get; set; } - [ApiMember(Name = "ControllableByUserId", Description = "Optional. Filter by sessions that a given user is allowed to remote control.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public Guid? ControllableByUserId { get; set; } @@ -258,11 +251,6 @@ namespace MediaBrowser.Api { var result = _sessionManager.Sessions.Where(i => i.IsActive); - if (request.SupportsRemoteControl.HasValue) - { - result = result.Where(i => i.SupportsRemoteControl == request.SupportsRemoteControl.Value); - } - if (!string.IsNullOrEmpty(request.DeviceId)) { result = result.Where(i => string.Equals(i.DeviceId, request.DeviceId, StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.Controller/Session/ISessionController.cs b/MediaBrowser.Controller/Session/ISessionController.cs index 9c818284d..1b50bad47 100644 --- a/MediaBrowser.Controller/Session/ISessionController.cs +++ b/MediaBrowser.Controller/Session/ISessionController.cs @@ -8,12 +8,6 @@ namespace MediaBrowser.Controller.Session public interface ISessionController { /// <summary> - /// Gets a value indicating whether [supports media remote control]. - /// </summary> - /// <value><c>true</c> if [supports media remote control]; otherwise, <c>false</c>.</value> - bool SupportsMediaRemoteControl { get; } - - /// <summary> /// Gets a value indicating whether this instance is session active. /// </summary> /// <value><c>true</c> if this instance is session active; otherwise, <c>false</c>.</value> diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 54d844c0a..9f5b687cc 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -139,23 +139,6 @@ namespace MediaBrowser.Controller.Session } } - /// <summary> - /// Gets a value indicating whether [supports remote control]. - /// </summary> - /// <value><c>true</c> if [supports remote control]; otherwise, <c>false</c>.</value> - public bool SupportsRemoteControl - { - get - { - if (SessionController != null) - { - return SessionController.SupportsMediaRemoteControl; - } - - return false; - } - } - public bool ContainsUser(Guid userId) { return (UserId ?? Guid.Empty) == UserId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); diff --git a/MediaBrowser.Dlna/PlayTo/PlayToController.cs b/MediaBrowser.Dlna/PlayTo/PlayToController.cs index ab342d635..f0fc8c485 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToController.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToController.cs @@ -38,11 +38,6 @@ namespace MediaBrowser.Dlna.PlayTo private readonly SsdpHandler _ssdpHandler; private readonly string _serverAddress; - public bool SupportsMediaRemoteControl - { - get { return true; } - } - public bool IsSessionActive { get diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 9ae4f4d5c..708f92264 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -560,9 +560,6 @@ <Compile Include="..\MediaBrowser.Model\MediaInfo\IBlurayExaminer.cs"> <Link>MediaInfo\IBlurayExaminer.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\MediaInfo\MediaStreamSelector.cs"> - <Link>MediaInfo\MediaStreamSelector.cs</Link> - </Compile> <Compile Include="..\MediaBrowser.Model\MediaInfo\SubtitleFormat.cs"> <Link>MediaInfo\SubtitleFormat.cs</Link> </Compile> @@ -839,9 +836,6 @@ <Compile Include="..\MediaBrowser.Model\Weather\WeatherUnits.cs"> <Link>Weather\WeatherUnits.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\Web\QueryStringDictionary.cs"> - <Link>Web\QueryStringDictionary.cs</Link> - </Compile> <Compile Include="..\SharedVersion.cs"> <Link>Properties\SharedVersion.cs</Link> </Compile> diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index fddccc09a..8e0a67dde 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -541,9 +541,6 @@ <Compile Include="..\MediaBrowser.Model\MediaInfo\IBlurayExaminer.cs"> <Link>MediaInfo\IBlurayExaminer.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\MediaInfo\MediaStreamSelector.cs"> - <Link>MediaInfo\MediaStreamSelector.cs</Link> - </Compile> <Compile Include="..\MediaBrowser.Model\MediaInfo\SubtitleFormat.cs"> <Link>MediaInfo\SubtitleFormat.cs</Link> </Compile> @@ -820,9 +817,6 @@ <Compile Include="..\MediaBrowser.Model\Weather\WeatherUnits.cs"> <Link>Weather\WeatherUnits.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\Web\QueryStringDictionary.cs"> - <Link>Web\QueryStringDictionary.cs</Link> - </Compile> <Compile Include="..\SharedVersion.cs"> <Link>Properties\SharedVersion.cs</Link> </Compile> diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 9bf52baed..131c36044 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -172,7 +172,6 @@ <Compile Include="Logging\NullLogger.cs" /> <Compile Include="MediaInfo\AudioCodec.cs" /> <Compile Include="MediaInfo\Container.cs" /> - <Compile Include="MediaInfo\MediaStreamSelector.cs" /> <Compile Include="MediaInfo\SubtitleFormat.cs" /> <Compile Include="MediaInfo\TransportStreamTimestamp.cs" /> <Compile Include="MediaInfo\VideoCodec.cs" /> @@ -314,7 +313,6 @@ <Compile Include="Updates\PackageVersionInfo.cs" /> <Compile Include="Users\AuthenticationResult.cs" /> <Compile Include="Weather\WeatherUnits.cs" /> - <Compile Include="Web\QueryStringDictionary.cs" /> <None Include="Fody.targets" /> <None Include="FodyWeavers.xml" /> <None Include="packages.config" /> diff --git a/MediaBrowser.Model/Querying/SessionQuery.cs b/MediaBrowser.Model/Querying/SessionQuery.cs index 77bfef05f..fa7df315c 100644 --- a/MediaBrowser.Model/Querying/SessionQuery.cs +++ b/MediaBrowser.Model/Querying/SessionQuery.cs @@ -10,10 +10,5 @@ namespace MediaBrowser.Model.Querying /// Filter by sessions that are allowed to be controlled by a given user /// </summary> public string ControllableByUserId { get; set; } - - /// <summary> - /// Filter by sessions that either do or do not support remote control. Default returns all sessions. - /// </summary> - public bool? SupportsRemoteControl { get; set; } } } diff --git a/MediaBrowser.Model/Web/QueryStringDictionary.cs b/MediaBrowser.Model/Web/QueryStringDictionary.cs deleted file mode 100644 index b011d4d9c..000000000 --- a/MediaBrowser.Model/Web/QueryStringDictionary.cs +++ /dev/null @@ -1,257 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; - -namespace MediaBrowser.Model.Web -{ - /// <summary> - /// Class QueryStringDictionary - /// </summary> - public class QueryStringDictionary : Dictionary<string, string> - { - /// <summary> - /// Initializes a new instance of the <see cref="QueryStringDictionary" /> class. - /// </summary> - public QueryStringDictionary() - : base(StringComparer.OrdinalIgnoreCase) - { - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void Add(string name, int value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void Add(string name, long value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void Add(string name, double value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// <summary> - /// Adds if not null or empty. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNullOrEmpty(string name, string value) - { - if (!string.IsNullOrEmpty(value)) - { - Add(name, value); - } - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNull(string name, int? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNull(string name, double? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNull(string name, long? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">if set to <c>true</c> [value].</param> - public void Add(string name, bool value) - { - Add(name, value.ToString()); - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">if set to <c>true</c> [value].</param> - public void AddIfNotNull(string name, bool? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - /// <exception cref="System.ArgumentNullException">value</exception> - public void Add(string name, IEnumerable<int> value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - Add(name, string.Join(",", value.Select(v => v.ToString(CultureInfo.InvariantCulture)).ToArray())); - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNull(string name, IEnumerable<int> value) - { - if (value != null) - { - Add(name, value); - } - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - /// <exception cref="System.ArgumentNullException">value</exception> - public void Add(string name, IEnumerable<string> value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - string paramValue = string.Join(",", value.ToArray()); - - Add(name, paramValue); - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - public void AddIfNotNull(string name, IEnumerable<string> value) - { - if (value != null) - { - Add(name, value); - } - } - - /// <summary> - /// Adds the specified name. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - /// <param name="delimiter">The delimiter.</param> - /// <exception cref="ArgumentNullException">value</exception> - public void Add(string name, IEnumerable<string> value, string delimiter) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - string paramValue = string.Join(delimiter, value.ToArray()); - - Add(name, paramValue); - } - - /// <summary> - /// Adds if not null. - /// </summary> - /// <param name="name">The name.</param> - /// <param name="value">The value.</param> - /// <param name="delimiter">The delimiter.</param> - public void AddIfNotNull(string name, IEnumerable<string> value, string delimiter) - { - if (value != null) - { - Add(name, value, delimiter); - } - } - - /// <summary> - /// Gets the query string. - /// </summary> - /// <returns>System.String.</returns> - public string GetQueryString() - { - string[] queryParams = this.Select(i => string.Format("{0}={1}", i.Key, GetEncodedValue(i.Value))).ToArray(); - - return string.Join("&", queryParams); - } - - /// <summary> - /// Gets the encoded value. - /// </summary> - /// <param name="value">The value.</param> - /// <returns>System.String.</returns> - private string GetEncodedValue(string value) - { - return value; - } - - /// <summary> - /// Gets the URL. - /// </summary> - /// <param name="prefix">The prefix.</param> - /// <returns>System.String.</returns> - public string GetUrl(string prefix) - { - string query = GetQueryString(); - - if (string.IsNullOrEmpty(query)) - { - return prefix; - } - - return prefix + "?" + query; - } - } -} diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 38d6034e4..bf77f1869 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -113,10 +113,26 @@ namespace MediaBrowser.Server.Implementations.Dto if (user != null && dto.MediaSources != null && item is Video) { + var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference) + ? new string[] { } + : new[] { user.Configuration.AudioLanguagePreference }; + + var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference) + ? new string[] { } + : new[] { user.Configuration.SubtitleLanguagePreference }; + foreach (var source in dto.MediaSources) { - //source.DefaultAudioStreamIndex = GetDefaultAudioStreamIndex(source, user.Configuration); - //source.DefaultSubtitleStreamIndex = GetDefaultSubtitleStreamIndex(source, user.Configuration); + source.DefaultAudioStreamIndex = MediaStreamSelector.GetDefaultAudioStreamIndex( + source.MediaStreams, preferredAudio, user.Configuration.PlayDefaultAudioTrack); + + var defaultAudioIndex = source.DefaultAudioStreamIndex; + var audioLangage = defaultAudioIndex == null + ? null + : source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault(); + + source.DefaultSubtitleStreamIndex = MediaStreamSelector.GetDefaultSubtitleStreamIndex(source.MediaStreams, preferredSubs, + user.Configuration.SubtitleMode, audioLangage); } } diff --git a/MediaBrowser.Model/MediaInfo/MediaStreamSelector.cs b/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs index e710b1d79..e5a859cdc 100644 --- a/MediaBrowser.Model/MediaInfo/MediaStreamSelector.cs +++ b/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace MediaBrowser.Model.MediaInfo +namespace MediaBrowser.Server.Implementations.Dto { public static class MediaStreamSelector { diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 9e1943131..9ff395b7e 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -64,6 +64,13 @@ "LabelAudioLanguagePreference": "Audio language preference:", "LabelSubtitleLanguagePreference": "Subtitle language preference:", "OptionDefaultSubtitles": "Default", + "OptionOnlyForcedSubtitles": "Only forced subtitles", + "OptionAlwaysPlaySubtitles": "Always play subtitles", + "OptionNoSubtitles": "None", + "OptionDefaultSubtitlesHelp": "Subtitles matching the language preference will be loaded when the audio is in a foreign language.", + "OptionOnlyForcedSubtitlesHelp": "Only subtitles marked as forced will be loaded.", + "OptionAlwaysPlaySubtitlesHelp": "Subtitles matching the language preference will be loaded regardless of the audio language.", + "OptionNoSubtitlesHelp": "Subtitles will not be loaded by default.", "TabProfiles": "Profiles", "TabSecurity": "Security", "ButtonAddUser": "Add User", diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 78d8da70d..2a1492c1f 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -111,6 +111,7 @@ <Compile Include="Drawing\PlayedIndicatorDrawer.cs" /> <Compile Include="Drawing\UnplayedCountIndicator.cs" /> <Compile Include="Dto\DtoService.cs" /> + <Compile Include="Dto\MediaStreamSelector.cs" /> <Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" /> <Compile Include="EntryPoints\ExternalPortForwarding.cs" /> <Compile Include="EntryPoints\LibraryChangedNotifier.cs" /> diff --git a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs index 024b0ec90..8d6289217 100644 --- a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs +++ b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs @@ -37,11 +37,6 @@ namespace MediaBrowser.Server.Implementations.Session _postUrl = postUrl; } - public bool SupportsMediaRemoteControl - { - get { return false; } - } - public bool IsSessionActive { get diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index d2a047b42..cf27df70d 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -704,24 +704,6 @@ namespace MediaBrowser.Server.Implementations.Session return session; } - /// <summary> - /// Gets the session for remote control. - /// </summary> - /// <param name="sessionId">The session id.</param> - /// <returns>SessionInfo.</returns> - /// <exception cref="ResourceNotFoundException"></exception> - private SessionInfo GetSessionForRemoteControl(string sessionId) - { - var session = GetSession(sessionId); - - if (!session.SupportsRemoteControl) - { - throw new ArgumentException(string.Format("Session {0} does not support remote control.", session.Id)); - } - - return session; - } - public Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken) { var generalCommand = new GeneralCommand @@ -742,7 +724,7 @@ namespace MediaBrowser.Server.Implementations.Session public Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken) { - var session = GetSessionForRemoteControl(sessionId); + var session = GetSession(sessionId); var controllingSession = GetSession(controllingSessionId); AssertCanControl(session, controllingSession); @@ -752,7 +734,7 @@ namespace MediaBrowser.Server.Implementations.Session public Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken) { - var session = GetSessionForRemoteControl(sessionId); + var session = GetSession(sessionId); var user = session.UserId.HasValue ? _userManager.GetUserById(session.UserId.Value) : null; @@ -886,7 +868,7 @@ namespace MediaBrowser.Server.Implementations.Session public Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken) { - var session = GetSessionForRemoteControl(sessionId); + var session = GetSession(sessionId); var controllingSession = GetSession(controllingSessionId); AssertCanControl(session, controllingSession); @@ -1157,7 +1139,6 @@ namespace MediaBrowser.Server.Implementations.Session Id = session.Id, LastActivityDate = session.LastActivityDate, NowPlayingPositionTicks = session.PlayState.PositionTicks, - SupportsRemoteControl = session.SupportsRemoteControl, IsPaused = session.PlayState.IsPaused, IsMuted = session.PlayState.IsMuted, NowViewingItem = session.NowViewingItem, diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 3b6ecd21e..0edd57d2a 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -27,14 +27,6 @@ namespace MediaBrowser.Server.Implementations.Session Sockets = new List<IWebSocketConnection>(); } - public bool SupportsMediaRemoteControl - { - get - { - return Sockets.Any(i => i.State == WebSocketState.Open); - } - } - public bool IsSessionActive { get |
