From 8819a9d478e6fc11dbfdcff80d9a2dc175953373 Mon Sep 17 00:00:00 2001 From: Ionut Andrei Oanca Date: Thu, 24 Sep 2020 23:04:21 +0200 Subject: Add playlist-sync and group-wait to SyncPlay --- MediaBrowser.Model/SyncPlay/GroupInfoDto.cs | 26 ++++---- MediaBrowser.Model/SyncPlay/GroupRepeatMode.cs | 23 +++++++ MediaBrowser.Model/SyncPlay/GroupShuffleMode.cs | 18 ++++++ MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs | 22 +++++++ MediaBrowser.Model/SyncPlay/GroupUpdateType.cs | 8 +-- MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs | 4 +- MediaBrowser.Model/SyncPlay/NewGroupRequest.cs | 16 +++++ MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs | 52 ++++++++++++++++ .../SyncPlay/PlayQueueUpdateReason.cs | 58 ++++++++++++++++++ MediaBrowser.Model/SyncPlay/PlaybackRequestType.cs | 70 +++++++++++++++++++--- MediaBrowser.Model/SyncPlay/QueueItem.cs | 24 ++++++++ MediaBrowser.Model/SyncPlay/SendCommand.cs | 6 ++ MediaBrowser.Model/SyncPlay/SendCommandType.cs | 11 +++- 13 files changed, 308 insertions(+), 30 deletions(-) create mode 100644 MediaBrowser.Model/SyncPlay/GroupRepeatMode.cs create mode 100644 MediaBrowser.Model/SyncPlay/GroupShuffleMode.cs create mode 100644 MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs create mode 100644 MediaBrowser.Model/SyncPlay/NewGroupRequest.cs create mode 100644 MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs create mode 100644 MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs create mode 100644 MediaBrowser.Model/SyncPlay/QueueItem.cs (limited to 'MediaBrowser.Model/SyncPlay') diff --git a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs index ac84a26dc3..255f6812bd 100644 --- a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs +++ b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace MediaBrowser.Model.SyncPlay { /// - /// Class GroupInfoView. + /// Class GroupInfoDto. /// public class GroupInfoDto { @@ -16,27 +16,27 @@ namespace MediaBrowser.Model.SyncPlay public string GroupId { get; set; } /// - /// Gets or sets the playing item id. + /// Gets or sets the group name. /// - /// The playing item id. - public string PlayingItemId { get; set; } + /// The group name. + public string GroupName { get; set; } /// - /// Gets or sets the playing item name. + /// Gets or sets the group state. /// - /// The playing item name. - public string PlayingItemName { get; set; } - - /// - /// Gets or sets the position ticks. - /// - /// The position ticks. - public long PositionTicks { get; set; } + /// The group state. + public GroupState State { get; set; } /// /// Gets or sets the participants. /// /// The participants. public IReadOnlyList Participants { get; set; } + + /// + /// Gets or sets the date when this dto has been updated. + /// + /// The date when this dto has been updated. + public string LastUpdatedAt { get; set; } } } diff --git a/MediaBrowser.Model/SyncPlay/GroupRepeatMode.cs b/MediaBrowser.Model/SyncPlay/GroupRepeatMode.cs new file mode 100644 index 0000000000..4895e57b7f --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/GroupRepeatMode.cs @@ -0,0 +1,23 @@ +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Enum GroupRepeatMode. + /// + public enum GroupRepeatMode + { + /// + /// Repeat one item only. + /// + RepeatOne = 0, + + /// + /// Cycle the playlist. + /// + RepeatAll = 1, + + /// + /// Do not repeat. + /// + RepeatNone = 2 + } +} diff --git a/MediaBrowser.Model/SyncPlay/GroupShuffleMode.cs b/MediaBrowser.Model/SyncPlay/GroupShuffleMode.cs new file mode 100644 index 0000000000..de860883c0 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/GroupShuffleMode.cs @@ -0,0 +1,18 @@ +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Enum GroupShuffleMode. + /// + public enum GroupShuffleMode + { + /// + /// Sorted playlist. + /// + Sorted = 0, + + /// + /// Shuffled playlist. + /// + Shuffle = 1 + } +} diff --git a/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs b/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs new file mode 100644 index 0000000000..7c7b267e6f --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/GroupStateUpdate.cs @@ -0,0 +1,22 @@ +#nullable disable + +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Class GroupStateUpdate. + /// + public class GroupStateUpdate + { + /// + /// Gets or sets the state of the group. + /// + /// The state of the group. + public GroupState State { get; set; } + + /// + /// Gets or sets the reason of the state change. + /// + /// The reason of the state change. + public PlaybackRequestType Reason { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/GroupUpdateType.cs b/MediaBrowser.Model/SyncPlay/GroupUpdateType.cs index c749f7b13a..7423bff117 100644 --- a/MediaBrowser.Model/SyncPlay/GroupUpdateType.cs +++ b/MediaBrowser.Model/SyncPlay/GroupUpdateType.cs @@ -26,14 +26,14 @@ namespace MediaBrowser.Model.SyncPlay GroupLeft, /// - /// The group-wait update. Tells members of the group that a user is buffering. + /// The group-state update. Tells members of the group that the state changed. /// - GroupWait, + StateUpdate, /// - /// The prepare-session update. Tells a user to load some content. + /// The play-queue update. Tells a user what's the playing queue of the group. /// - PrepareSession, + PlayQueue, /// /// The not-in-group error. Tells a user that they don't belong to a group. diff --git a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs b/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs index 0c77a61322..04f3a73b17 100644 --- a/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs +++ b/MediaBrowser.Model/SyncPlay/JoinGroupRequest.cs @@ -8,9 +8,9 @@ namespace MediaBrowser.Model.SyncPlay public class JoinGroupRequest { /// - /// Gets or sets the Group id. + /// Gets or sets the group id. /// - /// The Group id to join. + /// The id of the group to join. public Guid GroupId { get; set; } } } diff --git a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs new file mode 100644 index 0000000000..ccab5313f7 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs @@ -0,0 +1,16 @@ +#nullable disable + +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Class NewGroupRequest. + /// + public class NewGroupRequest + { + /// + /// Gets or sets the group name. + /// + /// The name of the new group. + public string GroupName { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs new file mode 100644 index 0000000000..5e2740a892 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs @@ -0,0 +1,52 @@ +#nullable disable + +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Class PlayQueueUpdate. + /// + public class PlayQueueUpdate + { + /// + /// Gets or sets the request type that originated this update. + /// + /// The reason for the update. + public PlayQueueUpdateReason Reason { get; set; } + + /// + /// Gets or sets the UTC time of the last change to the playing queue. + /// + /// The UTC time of the last change to the playing queue. + public string LastUpdate { get; set; } + + /// + /// Gets or sets the playlist. + /// + /// The playlist. + public QueueItem[] Playlist { get; set; } + + /// + /// Gets or sets the playing item index in the playlist. + /// + /// The playing item index in the playlist. + public int PlayingItemIndex { get; set; } + + /// + /// Gets or sets the start position ticks. + /// + /// The start position ticks. + public long StartPositionTicks { get; set; } + + /// + /// Gets or sets the shuffle mode. + /// + /// The shuffle mode. + public GroupShuffleMode ShuffleMode { get; set; } + + /// + /// Gets or sets the repeat mode. + /// + /// The repeat mode. + public GroupRepeatMode RepeatMode { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs new file mode 100644 index 0000000000..4b3f6eb4d6 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs @@ -0,0 +1,58 @@ +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Enum PlayQueueUpdateReason. + /// + public enum PlayQueueUpdateReason + { + /// + /// A user is requesting to play a new playlist. + /// + NewPlaylist = 0, + + /// + /// A user is changing the playing item. + /// + SetCurrentItem = 1, + + /// + /// A user is removing items from the playlist. + /// + RemoveItems = 2, + + /// + /// A user is moving an item in the playlist. + /// + MoveItem = 3, + + /// + /// A user is making changes to the queue. + /// + Queue = 4, + + /// + /// A user is making changes to the queue. + /// + QueueNext = 5, + + /// + /// A user is requesting the next item in queue. + /// + NextTrack = 6, + + /// + /// A user is requesting the previous item in queue. + /// + PreviousTrack = 7, + + /// + /// A user is changing repeat mode. + /// + RepeatMode = 8, + + /// + /// A user is changing shuffle mode. + /// + ShuffleMode = 9 + } +} diff --git a/MediaBrowser.Model/SyncPlay/PlaybackRequestType.cs b/MediaBrowser.Model/SyncPlay/PlaybackRequestType.cs index e89efeed8a..0d0f48ea97 100644 --- a/MediaBrowser.Model/SyncPlay/PlaybackRequestType.cs +++ b/MediaBrowser.Model/SyncPlay/PlaybackRequestType.cs @@ -6,33 +6,87 @@ namespace MediaBrowser.Model.SyncPlay public enum PlaybackRequestType { /// - /// A user is requesting a play command for the group. + /// A user is setting a new playlist. /// Play = 0, + /// + /// A user is changing the playlist item. + /// + SetPlaylistItem = 1, + + /// + /// A user is removing items from the playlist. + /// + RemoveFromPlaylist = 2, + + /// + /// A user is moving an item in the playlist. + /// + MovePlaylistItem = 3, + + /// + /// A user is adding items to the playlist. + /// + Queue = 4, + + /// + /// A user is requesting an unpause command for the group. + /// + Unpause = 5, + /// /// A user is requesting a pause command for the group. /// - Pause = 1, + Pause = 6, /// - /// A user is requesting a seek command for the group. + /// A user is requesting a stop command for the group. /// - Seek = 2, + Stop = 7, /// + /// A user is requesting a seek command for the group. + /// + Seek = 8, + + /// /// A user is signaling that playback is buffering. /// - Buffer = 3, + Buffer = 9, /// /// A user is signaling that playback resumed. /// - Ready = 4, + Ready = 10, + + /// + /// A user is requesting next track in playlist. + /// + NextTrack = 11, + + /// + /// A user is requesting previous track in playlist. + /// + PreviousTrack = 12, + /// + /// A user is setting the repeat mode. + /// + SetRepeatMode = 13, + + /// + /// A user is setting the shuffle mode. + /// + SetShuffleMode = 14, + + /// + /// A user is reporting their ping. + /// + Ping = 15, /// - /// A user is reporting its ping. + /// A user is requesting to be ignored on group wait. /// - Ping = 5 + IgnoreWait = 16 } } diff --git a/MediaBrowser.Model/SyncPlay/QueueItem.cs b/MediaBrowser.Model/SyncPlay/QueueItem.cs new file mode 100644 index 0000000000..dc9cfbc229 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/QueueItem.cs @@ -0,0 +1,24 @@ +#nullable disable + +using System; + +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Class QueueItem. + /// + public class QueueItem + { + /// + /// Gets or sets the item id. + /// + /// The item id. + public Guid ItemId { get; set; } + + /// + /// Gets or sets the playlist id of the item. + /// + /// The playlist id of the item. + public string PlaylistItemId { get; set; } + } +} diff --git a/MediaBrowser.Model/SyncPlay/SendCommand.cs b/MediaBrowser.Model/SyncPlay/SendCommand.cs index 0f0be0152d..779f711af0 100644 --- a/MediaBrowser.Model/SyncPlay/SendCommand.cs +++ b/MediaBrowser.Model/SyncPlay/SendCommand.cs @@ -13,6 +13,12 @@ namespace MediaBrowser.Model.SyncPlay /// The group identifier. public string GroupId { get; set; } + /// + /// Gets or sets the playlist id of the playing item. + /// + /// The playlist id of the playing item. + public string PlaylistItemId { get; set; } + /// /// Gets or sets the UTC time when to execute the command. /// diff --git a/MediaBrowser.Model/SyncPlay/SendCommandType.cs b/MediaBrowser.Model/SyncPlay/SendCommandType.cs index 86dec9e900..e6b17c60ae 100644 --- a/MediaBrowser.Model/SyncPlay/SendCommandType.cs +++ b/MediaBrowser.Model/SyncPlay/SendCommandType.cs @@ -6,18 +6,23 @@ namespace MediaBrowser.Model.SyncPlay public enum SendCommandType { /// - /// The play command. Instructs users to start playback. + /// The unpause command. Instructs users to unpause playback. /// - Play = 0, + Unpause = 0, /// /// The pause command. Instructs users to pause playback. /// Pause = 1, + /// + /// The stop command. Instructs users to stop playback. + /// + Stop = 2, + /// /// The seek command. Instructs users to seek to a specified time. /// - Seek = 2 + Seek = 3 } } -- cgit v1.2.3