From d5e49f590d8e027a8755ea607bf3caba3ddcc9f1 Mon Sep 17 00:00:00 2001 From: Tim Hobbs Date: Thu, 20 Mar 2014 12:12:10 -0700 Subject: [PATCH] Enable remote "fullscreen" command This is really only pseudo-fullscreen, as the js fullscreen API doesn't allow fullscreen without user interaction. --- MediaBrowser.Api/SessionsService.cs | 2 +- MediaBrowser.Dlna/PlayTo/Device.cs | 29 +++++++++++++++++++ MediaBrowser.Dlna/PlayTo/DlnaController.cs | 3 ++ .../Session/PlaystateCommand.cs | 6 +++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index df35c93a02..62e5a252ec 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -131,7 +131,7 @@ namespace MediaBrowser.Api /// Gets or sets the play command. /// /// The play command. - [ApiMember(Name = "Command", Description = "The command to send - stop, pause, unpause, nexttrack, previoustrack, seek.", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + [ApiMember(Name = "Command", Description = "The command to send - stop, pause, unpause, nexttrack, previoustrack, seek, fullscreen.", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public PlaystateCommand Command { get; set; } } diff --git a/MediaBrowser.Dlna/PlayTo/Device.cs b/MediaBrowser.Dlna/PlayTo/Device.cs index 5952a213ae..b05a47491d 100644 --- a/MediaBrowser.Dlna/PlayTo/Device.cs +++ b/MediaBrowser.Dlna/PlayTo/Device.cs @@ -30,6 +30,15 @@ namespace MediaBrowser.Dlna.PlayTo } } + private bool _fullscreen; + public bool IsFullscreen + { + get + { + return _fullscreen; + } + } + private string _currentId = String.Empty; public string CurrentId { @@ -207,6 +216,26 @@ namespace MediaBrowser.Dlna.PlayTo return SetVolume(tmp); } + public async Task ToggleFullscreen() + { + var command = RendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "Fullscreen"); + if (command == null) + return true; + + var service = Properties.Services.FirstOrDefault(s => s.ServiceType == ServiceRenderingType); + + if (service == null) { + throw new InvalidOperationException("Unable to find service"); + } + + _fullscreen = !_fullscreen; + + var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, _fullscreen)) + .ConfigureAwait(false); + + return true; + } + public async Task SetVolume(int value) { var command = RendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume"); diff --git a/MediaBrowser.Dlna/PlayTo/DlnaController.cs b/MediaBrowser.Dlna/PlayTo/DlnaController.cs index 4180154a40..dc62d60627 100644 --- a/MediaBrowser.Dlna/PlayTo/DlnaController.cs +++ b/MediaBrowser.Dlna/PlayTo/DlnaController.cs @@ -283,6 +283,9 @@ namespace MediaBrowser.Dlna.PlayTo case PlaystateCommand.PreviousTrack: _currentItem = null; return SetPrevious(); + + case PlaystateCommand.Fullscreen: + return _device.ToggleFullscreen(); } return Task.FromResult(true); diff --git a/MediaBrowser.Model/Session/PlaystateCommand.cs b/MediaBrowser.Model/Session/PlaystateCommand.cs index b0dec66d4f..d83c6dae54 100644 --- a/MediaBrowser.Model/Session/PlaystateCommand.cs +++ b/MediaBrowser.Model/Session/PlaystateCommand.cs @@ -29,7 +29,11 @@ namespace MediaBrowser.Model.Session /// /// The seek /// - Seek + Seek, + /// + /// The fullscreen + /// + Fullscreen } public class PlaystateRequest