diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index 82b6229a19..e688973f9e 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> { - /// - /// Gets or sets a value indicating whether [supports remote control]. - /// - /// null if [supports remote control] contains no value, true if [supports remote control]; otherwise, false. - [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 9c818284d7..1b50bad47d 100644 --- a/MediaBrowser.Controller/Session/ISessionController.cs +++ b/MediaBrowser.Controller/Session/ISessionController.cs @@ -7,12 +7,6 @@ namespace MediaBrowser.Controller.Session { public interface ISessionController { - /// - /// Gets a value indicating whether [supports media remote control]. - /// - /// true if [supports media remote control]; otherwise, false. - bool SupportsMediaRemoteControl { get; } - /// /// Gets a value indicating whether this instance is session active. /// diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 54d844c0a3..9f5b687cc4 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -139,23 +139,6 @@ namespace MediaBrowser.Controller.Session } } - /// - /// Gets a value indicating whether [supports remote control]. - /// - /// true if [supports remote control]; otherwise, false. - 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 ab342d635e..f0fc8c4857 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 9ae4f4d5c5..708f922648 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -560,9 +560,6 @@ MediaInfo\IBlurayExaminer.cs - - MediaInfo\MediaStreamSelector.cs - MediaInfo\SubtitleFormat.cs @@ -839,9 +836,6 @@ Weather\WeatherUnits.cs - - Web\QueryStringDictionary.cs - Properties\SharedVersion.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index fddccc09a3..8e0a67dde3 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -541,9 +541,6 @@ MediaInfo\IBlurayExaminer.cs - - MediaInfo\MediaStreamSelector.cs - MediaInfo\SubtitleFormat.cs @@ -820,9 +817,6 @@ Weather\WeatherUnits.cs - - Web\QueryStringDictionary.cs - Properties\SharedVersion.cs diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 9bf52baedd..131c36044d 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -172,7 +172,6 @@ - @@ -314,7 +313,6 @@ - diff --git a/MediaBrowser.Model/Querying/SessionQuery.cs b/MediaBrowser.Model/Querying/SessionQuery.cs index 77bfef05fb..fa7df315ca 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 /// public string ControllableByUserId { get; set; } - - /// - /// Filter by sessions that either do or do not support remote control. Default returns all sessions. - /// - public bool? SupportsRemoteControl { get; set; } } } diff --git a/MediaBrowser.Model/Web/QueryStringDictionary.cs b/MediaBrowser.Model/Web/QueryStringDictionary.cs deleted file mode 100644 index b011d4d9cb..0000000000 --- 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 -{ - /// - /// Class QueryStringDictionary - /// - public class QueryStringDictionary : Dictionary - { - /// - /// Initializes a new instance of the class. - /// - public QueryStringDictionary() - : base(StringComparer.OrdinalIgnoreCase) - { - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - public void Add(string name, int value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - public void Add(string name, long value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - public void Add(string name, double value) - { - Add(name, value.ToString(CultureInfo.InvariantCulture)); - } - - /// - /// Adds if not null or empty. - /// - /// The name. - /// The value. - public void AddIfNotNullOrEmpty(string name, string value) - { - if (!string.IsNullOrEmpty(value)) - { - Add(name, value); - } - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - public void AddIfNotNull(string name, int? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - public void AddIfNotNull(string name, double? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - public void AddIfNotNull(string name, long? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// - /// Adds the specified name. - /// - /// The name. - /// if set to true [value]. - public void Add(string name, bool value) - { - Add(name, value.ToString()); - } - - /// - /// Adds if not null. - /// - /// The name. - /// if set to true [value]. - public void AddIfNotNull(string name, bool? value) - { - if (value.HasValue) - { - Add(name, value.Value); - } - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - /// value - public void Add(string name, IEnumerable value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - Add(name, string.Join(",", value.Select(v => v.ToString(CultureInfo.InvariantCulture)).ToArray())); - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - public void AddIfNotNull(string name, IEnumerable value) - { - if (value != null) - { - Add(name, value); - } - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - /// value - public void Add(string name, IEnumerable value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - string paramValue = string.Join(",", value.ToArray()); - - Add(name, paramValue); - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - public void AddIfNotNull(string name, IEnumerable value) - { - if (value != null) - { - Add(name, value); - } - } - - /// - /// Adds the specified name. - /// - /// The name. - /// The value. - /// The delimiter. - /// value - public void Add(string name, IEnumerable value, string delimiter) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - string paramValue = string.Join(delimiter, value.ToArray()); - - Add(name, paramValue); - } - - /// - /// Adds if not null. - /// - /// The name. - /// The value. - /// The delimiter. - public void AddIfNotNull(string name, IEnumerable value, string delimiter) - { - if (value != null) - { - Add(name, value, delimiter); - } - } - - /// - /// Gets the query string. - /// - /// System.String. - public string GetQueryString() - { - string[] queryParams = this.Select(i => string.Format("{0}={1}", i.Key, GetEncodedValue(i.Value))).ToArray(); - - return string.Join("&", queryParams); - } - - /// - /// Gets the encoded value. - /// - /// The value. - /// System.String. - private string GetEncodedValue(string value) - { - return value; - } - - /// - /// Gets the URL. - /// - /// The prefix. - /// System.String. - 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 38d6034e4f..bf77f18696 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 similarity index 98% rename from MediaBrowser.Model/MediaInfo/MediaStreamSelector.cs rename to MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs index e710b1d79d..e5a859cdc8 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 9e19431310..9ff395b7ed 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 78d8da70dc..2a1492c1f1 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -111,6 +111,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs index 024b0ec906..8d6289217d 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 d2a047b42f..cf27df70df 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; } - /// - /// Gets the session for remote control. - /// - /// The session id. - /// SessionInfo. - /// - 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 3b6ecd21e9..0edd57d2a8 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(); } - public bool SupportsMediaRemoteControl - { - get - { - return Sockets.Any(i => i.State == WebSocketState.Open); - } - } - public bool IsSessionActive { get