Implement TransportState according to spec (#7426)

This commit is contained in:
Bond-009 2022-03-08 16:12:03 +01:00 committed by GitHub
parent e3ea899bcc
commit 03f1eff21a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View File

@ -69,11 +69,11 @@ namespace Emby.Dlna.PlayTo
public TransportState TransportState { get; private set; } 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; } public Action OnDeviceUnavailable { get; set; }
@ -494,7 +494,7 @@ namespace Emby.Dlna.PlayTo
cancellationToken: cancellationToken) cancellationToken: cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
TransportState = TransportState.Paused; TransportState = TransportState.PAUSED_PLAYBACK;
RestartTimer(true); RestartTimer(true);
} }
@ -527,7 +527,7 @@ namespace Emby.Dlna.PlayTo
if (transportState.HasValue) if (transportState.HasValue)
{ {
// If we're not playing anything no need to get additional data // 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); 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 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(); RestartTimerInactive();
} }
@ -1229,7 +1229,7 @@ namespace Emby.Dlna.PlayTo
} }
else if (previousMediaInfo == null) else if (previousMediaInfo == null)
{ {
if (state != TransportState.Stopped) if (state != TransportState.STOPPED)
{ {
OnPlaybackStart(mediaInfo); OnPlaybackStart(mediaInfo);
} }

View File

@ -816,7 +816,7 @@ namespace Emby.Dlna.PlayTo
const int Interval = 500; const int Interval = 500;
var currentWait = 0; var currentWait = 0;
while (_device.TransportState != TransportState.Playing && currentWait < MaxWait) while (_device.TransportState != TransportState.PLAYING && currentWait < MaxWait)
{ {
await Task.Delay(Interval, cancellationToken).ConfigureAwait(false); await Task.Delay(Interval, cancellationToken).ConfigureAwait(false);
currentWait += Interval; currentWait += Interval;

View File

@ -2,12 +2,15 @@
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
/// <summary>
/// Core of the AVTransport service. It defines the conceptually top-
/// level state of the transport, for example, whether it is playing, recording, etc.
/// </summary>
public enum TransportState public enum TransportState
{ {
Stopped, STOPPED,
Playing, PLAYING,
Transitioning, TRANSITIONING,
PausedPlayback, PAUSED_PLAYBACK
Paused
} }
} }