mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Clear playlist in SyncPlay group
This commit is contained in:
parent
828b0be254
commit
68969c9530
@ -534,6 +534,16 @@ namespace Emby.Server.Implementations.SyncPlay
|
|||||||
return itemFound;
|
return itemFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void ClearPlayQueue(bool clearPlayingItem)
|
||||||
|
{
|
||||||
|
PlayQueue.ClearPlaylist(clearPlayingItem);
|
||||||
|
if (clearPlayingItem)
|
||||||
|
{
|
||||||
|
RestartCurrentItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds)
|
public bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds)
|
||||||
{
|
{
|
||||||
|
@ -162,7 +162,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[FromBody, Required] RemoveFromPlaylistRequestDto requestData)
|
[FromBody, Required] RemoveFromPlaylistRequestDto requestData)
|
||||||
{
|
{
|
||||||
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
||||||
var syncPlayRequest = new RemoveFromPlaylistGroupRequest(requestData.PlaylistItemIds);
|
var syncPlayRequest = new RemoveFromPlaylistGroupRequest(requestData.PlaylistItemIds, requestData.ClearPlaylist, requestData.ClearPlayingItem);
|
||||||
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,21 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the playlist identifiers ot the items.
|
/// Gets or sets the playlist identifiers ot the items. Ignored when clearing the playlist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The playlist identifiers ot the items.</value>
|
/// <value>The playlist identifiers ot the items.</value>
|
||||||
public IReadOnlyList<Guid> PlaylistItemIds { get; set; }
|
public IReadOnlyList<Guid> PlaylistItemIds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the entire playlist should be cleared.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>Whether the entire playlist should be cleared.</value>
|
||||||
|
public bool ClearPlaylist { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the playing item should be removed as well. Used only when clearing the playlist.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>Whether the playing item should be removed as well.</value>
|
||||||
|
public bool ClearPlayingItem { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,16 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void HandleRequest(RemoveFromPlaylistGroupRequest request, IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken)
|
public virtual void HandleRequest(RemoveFromPlaylistGroupRequest request, IGroupStateContext context, GroupStateType prevState, SessionInfo session, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var playingItemRemoved = context.RemoveFromPlayQueue(request.PlaylistItemIds);
|
bool playingItemRemoved;
|
||||||
|
if (request.ClearPlaylist)
|
||||||
|
{
|
||||||
|
context.ClearPlayQueue(request.ClearPlayingItem);
|
||||||
|
playingItemRemoved = request.ClearPlayingItem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playingItemRemoved = context.RemoveFromPlayQueue(request.PlaylistItemIds);
|
||||||
|
}
|
||||||
|
|
||||||
var playQueueUpdate = context.GetPlayQueueUpdate(PlayQueueUpdateReason.RemoveItems);
|
var playQueueUpdate = context.GetPlayQueueUpdate(PlayQueueUpdateReason.RemoveItems);
|
||||||
var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate);
|
var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate);
|
||||||
|
@ -160,6 +160,12 @@ namespace MediaBrowser.Controller.SyncPlay
|
|||||||
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
|
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
|
||||||
bool SetPlayingItem(Guid playlistItemId);
|
bool SetPlayingItem(Guid playlistItemId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears the play queue.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clearPlayingItem">Whether to remove the playing item as well.</param>
|
||||||
|
void ClearPlayQueue(bool clearPlayingItem);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes items from the play queue.
|
/// Removes items from the play queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -15,9 +15,14 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
|
|||||||
/// Initializes a new instance of the <see cref="RemoveFromPlaylistGroupRequest"/> class.
|
/// Initializes a new instance of the <see cref="RemoveFromPlaylistGroupRequest"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="items">The playlist ids of the items to remove.</param>
|
/// <param name="items">The playlist ids of the items to remove.</param>
|
||||||
public RemoveFromPlaylistGroupRequest(IReadOnlyList<Guid> items)
|
/// <param name="clearPlaylist">Whether to clear the entire playlist. The items list will be ignored.</param>
|
||||||
|
/// <param name="clearPlayingItem">Whether to remove the playing item as well. Used only when clearing the playlist.</param>
|
||||||
|
|
||||||
|
public RemoveFromPlaylistGroupRequest(IReadOnlyList<Guid> items, bool clearPlaylist = false, bool clearPlayingItem = false)
|
||||||
{
|
{
|
||||||
PlaylistItemIds = items ?? Array.Empty<Guid>();
|
PlaylistItemIds = items ?? Array.Empty<Guid>();
|
||||||
|
ClearPlaylist = clearPlaylist;
|
||||||
|
ClearPlayingItem = clearPlayingItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -26,6 +31,18 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
|
|||||||
/// <value>The playlist identifiers ot the items.</value>
|
/// <value>The playlist identifiers ot the items.</value>
|
||||||
public IReadOnlyList<Guid> PlaylistItemIds { get; }
|
public IReadOnlyList<Guid> PlaylistItemIds { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the entire playlist should be cleared.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>Whether the entire playlist should be cleared.</value>
|
||||||
|
public bool ClearPlaylist { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the playing item should be removed as well.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>Whether the playing item should be removed as well.</value>
|
||||||
|
public bool ClearPlayingItem { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist;
|
public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user