From 03f1eff21abf75d88d15df05b6a841e48943c7ef Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 8 Mar 2022 16:12:03 +0100 Subject: [PATCH] Implement TransportState according to spec (#7426) --- Emby.Dlna/PlayTo/Device.cs | 14 +++++++------- Emby.Dlna/PlayTo/PlayToController.cs | 2 +- Emby.Dlna/PlayTo/TransportState.cs | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index 7815e92937..8eb90f4455 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -69,11 +69,11 @@ namespace Emby.Dlna.PlayTo public TransportState TransportState { get; private set; } - public bool IsPlaying => TransportState == TransportState.Playing; + public bool IsPlaying => TransportState == TransportState.PLAYING; - public bool IsPaused => TransportState == TransportState.Paused || TransportState == TransportState.PausedPlayback; + public bool IsPaused => TransportState == TransportState.PAUSED_PLAYBACK; - public bool IsStopped => TransportState == TransportState.Stopped; + public bool IsStopped => TransportState == TransportState.STOPPED; public Action OnDeviceUnavailable { get; set; } @@ -494,7 +494,7 @@ namespace Emby.Dlna.PlayTo cancellationToken: cancellationToken) .ConfigureAwait(false); - TransportState = TransportState.Paused; + TransportState = TransportState.PAUSED_PLAYBACK; RestartTimer(true); } @@ -527,7 +527,7 @@ namespace Emby.Dlna.PlayTo if (transportState.HasValue) { // If we're not playing anything no need to get additional data - if (transportState.Value == TransportState.Stopped) + if (transportState.Value == TransportState.STOPPED) { UpdateMediaInfo(null, transportState.Value); } @@ -556,7 +556,7 @@ namespace Emby.Dlna.PlayTo } // If we're not playing anything make sure we don't get data more often than necessary to keep the Session alive - if (transportState.Value == TransportState.Stopped) + if (transportState.Value == TransportState.STOPPED) { RestartTimerInactive(); } @@ -1229,7 +1229,7 @@ namespace Emby.Dlna.PlayTo } else if (previousMediaInfo == null) { - if (state != TransportState.Stopped) + if (state != TransportState.STOPPED) { OnPlaybackStart(mediaInfo); } diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index e147cb977e..d84ed69f28 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -816,7 +816,7 @@ namespace Emby.Dlna.PlayTo const int Interval = 500; var currentWait = 0; - while (_device.TransportState != TransportState.Playing && currentWait < MaxWait) + while (_device.TransportState != TransportState.PLAYING && currentWait < MaxWait) { await Task.Delay(Interval, cancellationToken).ConfigureAwait(false); currentWait += Interval; diff --git a/Emby.Dlna/PlayTo/TransportState.cs b/Emby.Dlna/PlayTo/TransportState.cs index 2058e9dc79..0d6a78438c 100644 --- a/Emby.Dlna/PlayTo/TransportState.cs +++ b/Emby.Dlna/PlayTo/TransportState.cs @@ -2,12 +2,15 @@ namespace Emby.Dlna.PlayTo { + /// + /// Core of the AVTransport service. It defines the conceptually top- + /// level state of the transport, for example, whether it is playing, recording, etc. + /// public enum TransportState { - Stopped, - Playing, - Transitioning, - PausedPlayback, - Paused + STOPPED, + PLAYING, + TRANSITIONING, + PAUSED_PLAYBACK } }