Handle ignore-wait request in waiting state in SyncPlay

This commit is contained in:
Ionut Andrei Oanca
2020-11-14 18:09:25 +01:00
parent 83333e1fe8
commit fa69f6fd51
6 changed files with 68 additions and 68 deletions

View File

@@ -24,13 +24,7 @@ namespace MediaBrowser.Controller.SyncPlay
}
/// <inheritdoc />
public override GroupStateType Type
{
get
{
return GroupStateType.Idle;
}
}
public override GroupStateType Type { get; } = GroupStateType.Idle;
/// <inheritdoc />
public override void SessionJoined(IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken)

View File

@@ -25,13 +25,7 @@ namespace MediaBrowser.Controller.SyncPlay
}
/// <inheritdoc />
public override GroupStateType Type
{
get
{
return GroupStateType.Paused;
}
}
public override GroupStateType Type { get; } = GroupStateType.Paused;
/// <inheritdoc />
public override void SessionJoined(IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken)

View File

@@ -25,13 +25,7 @@ namespace MediaBrowser.Controller.SyncPlay
}
/// <inheritdoc />
public override GroupStateType Type
{
get
{
return GroupStateType.Playing;
}
}
public override GroupStateType Type { get; } = GroupStateType.Playing;
/// <summary>
/// Gets or sets a value indicating whether requests for buffering should be ignored.

View File

@@ -25,13 +25,7 @@ namespace MediaBrowser.Controller.SyncPlay
}
/// <inheritdoc />
public override GroupStateType Type
{
get
{
return GroupStateType.Waiting;
}
}
public override GroupStateType Type { get; } = GroupStateType.Waiting;
/// <summary>
/// Gets or sets a value indicating whether playback should resume when group is ready.
@@ -651,5 +645,31 @@ namespace MediaBrowser.Controller.SyncPlay
Logger.LogDebug("HandleRequest: {0} in group {1}, no previous track available.", request.Type, context.GroupId.ToString());
}
}
/// <inheritdoc />
public override void HandleRequest(IGroupStateContext context, GroupStateType prevState, IgnoreWaitGroupRequest request, SessionInfo session, CancellationToken cancellationToken)
{
context.SetIgnoreGroupWait(session, request.IgnoreWait);
if (!context.IsBuffering())
{
Logger.LogDebug("HandleRequest: {0} in group {1}, returning to previous state.", request.Type, context.GroupId.ToString());
if (ResumePlaying)
{
// Client, that was buffering, stopped following playback.
var playingState = new PlayingGroupState(Logger);
context.SetState(playingState);
var unpauseRequest = new UnpauseGroupRequest();
playingState.HandleRequest(context, Type, unpauseRequest, session, cancellationToken);
}
else
{
// Group is ready, returning to previous state.
var pausedState = new PausedGroupState(Logger);
context.SetState(pausedState);
}
}
}
}
}