From d365e1df238acfdc974ea8f42668d2c88a3d961f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 5 Jan 2014 00:34:06 -0500 Subject: [PATCH] fixes #574 - Add ability to report playable media types --- MediaBrowser.Api/SessionsService.cs | 24 +++++++++++++++++++ .../Session/SessionInfo.cs | 21 +++++++++++++--- MediaBrowser.Model/Session/SessionInfoDto.cs | 9 +++++++ .../Dto/DtoService.cs | 1 + 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index 8d5e9e0d7d..5433ecc2e3 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -194,6 +194,21 @@ namespace MediaBrowser.Api public Guid UserId { get; set; } } + [Route("/Sessions/{Id}/Capabilities", "POST")] + [Api(("Updates capabilities for a device"))] + public class PostCapabilities : IReturnVoid + { + /// + /// Gets or sets the id. + /// + /// The id. + [ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public Guid Id { get; set; } + + [ApiMember(Name = "PlayableMediaTypes", Description = "A list of playable media types, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string PlayableMediaTypes { get; set; } + } + /// /// Class SessionsService /// @@ -335,5 +350,14 @@ namespace MediaBrowser.Api { _sessionManager.RemoveAdditionalUser(request.Id, request.UserId); } + + public void Post(PostCapabilities request) + { + var session = _sessionManager.Sessions.First(i => i.Id == request.Id); + + session.PlayableMediaTypes = request.PlayableMediaTypes + .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .ToList(); + } } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index b05a68a842..f84204d11b 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Session; using System; using System.Collections.Generic; @@ -14,12 +15,20 @@ namespace MediaBrowser.Controller.Session public SessionInfo() { QueueableMediaTypes = new List(); + PlayableMediaTypes = new List + { + MediaType.Audio, + MediaType.Book, + MediaType.Game, + MediaType.Photo, + MediaType.Video + }; AdditionalUsers = new List(); } public List AdditionalUsers { get; set; } - + /// /// Gets or sets the remote end point. /// @@ -37,7 +46,13 @@ namespace MediaBrowser.Controller.Session /// /// The queueable media types. public List QueueableMediaTypes { get; set; } - + + /// + /// Gets or sets the playable media types. + /// + /// The playable media types. + public List PlayableMediaTypes { get; set; } + /// /// Gets or sets the id. /// @@ -169,7 +184,7 @@ namespace MediaBrowser.Controller.Session { return SessionController.SupportsMediaRemoteControl; } - + return false; } } diff --git a/MediaBrowser.Model/Session/SessionInfoDto.cs b/MediaBrowser.Model/Session/SessionInfoDto.cs index 7116900227..dabafad7ba 100644 --- a/MediaBrowser.Model/Session/SessionInfoDto.cs +++ b/MediaBrowser.Model/Session/SessionInfoDto.cs @@ -24,6 +24,12 @@ namespace MediaBrowser.Model.Session /// /// The queueable media types. public List QueueableMediaTypes { get; set; } + + /// + /// Gets or sets the playable media types. + /// + /// The playable media types. + public List PlayableMediaTypes { get; set; } /// /// Gets or sets the id. @@ -138,6 +144,9 @@ namespace MediaBrowser.Model.Session public SessionInfoDto() { AdditionalUsers = new List(); + + PlayableMediaTypes = new List(); + QueueableMediaTypes = new List(); } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 0f6d680b12..59accba1f3 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -244,6 +244,7 @@ namespace MediaBrowser.Server.Implementations.Dto ApplicationVersion = session.ApplicationVersion, CanSeek = session.CanSeek, QueueableMediaTypes = session.QueueableMediaTypes, + PlayableMediaTypes = session.PlayableMediaTypes, RemoteEndPoint = session.RemoteEndPoint, AdditionalUsers = session.AdditionalUsers };