RemoveFromPlaylistGroupRequest.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #nullable disable
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using MediaBrowser.Controller.Session;
  6. using MediaBrowser.Model.SyncPlay;
  7. namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
  8. {
  9. /// <summary>
  10. /// Class RemoveFromPlaylistGroupRequest.
  11. /// </summary>
  12. public class RemoveFromPlaylistGroupRequest : AbstractPlaybackRequest
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="RemoveFromPlaylistGroupRequest"/> class.
  16. /// </summary>
  17. /// <param name="items">The playlist ids of the items to remove.</param>
  18. /// <param name="clearPlaylist">Whether to clear the entire playlist. The items list will be ignored.</param>
  19. /// <param name="clearPlayingItem">Whether to remove the playing item as well. Used only when clearing the playlist.</param>
  20. public RemoveFromPlaylistGroupRequest(IReadOnlyList<Guid> items, bool clearPlaylist = false, bool clearPlayingItem = false)
  21. {
  22. PlaylistItemIds = items ?? Array.Empty<Guid>();
  23. ClearPlaylist = clearPlaylist;
  24. ClearPlayingItem = clearPlayingItem;
  25. }
  26. /// <summary>
  27. /// Gets the playlist identifiers of the items.
  28. /// </summary>
  29. /// <value>The playlist identifiers of the items.</value>
  30. public IReadOnlyList<Guid> PlaylistItemIds { get; }
  31. /// <summary>
  32. /// Gets a value indicating whether the entire playlist should be cleared.
  33. /// </summary>
  34. /// <value>Whether the entire playlist should be cleared.</value>
  35. public bool ClearPlaylist { get; }
  36. /// <summary>
  37. /// Gets a value indicating whether the playing item should be removed as well.
  38. /// </summary>
  39. /// <value>Whether the playing item should be removed as well.</value>
  40. public bool ClearPlayingItem { get; }
  41. /// <inheritdoc />
  42. public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist;
  43. /// <inheritdoc />
  44. public override void Apply(IGroupStateContext context, IGroupState state, SessionInfo session, CancellationToken cancellationToken)
  45. {
  46. state.HandleRequest(this, context, state.Type, session, cancellationToken);
  47. }
  48. }
  49. }