Merge pull request #3194 from OancaAndrei/syncplay-enhanced

SyncPlay for TV series (and Music)
This commit is contained in:
Joshua M. Boniface
2020-12-04 20:22:30 -05:00
committed by GitHub
91 changed files with 5555 additions and 1356 deletions

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class GroupInfoDto.
/// </summary>
public class GroupInfoDto
{
/// <summary>
/// Initializes a new instance of the <see cref="GroupInfoDto"/> class.
/// </summary>
/// <param name="groupId">The group identifier.</param>
/// <param name="groupName">The group name.</param>
/// <param name="state">The group state.</param>
/// <param name="participants">The participants.</param>
/// <param name="lastUpdatedAt">The date when this DTO has been created.</param>
public GroupInfoDto(Guid groupId, string groupName, GroupStateType state, IReadOnlyList<string> participants, DateTime lastUpdatedAt)
{
GroupId = groupId;
GroupName = groupName;
State = state;
Participants = participants;
LastUpdatedAt = lastUpdatedAt;
}
/// <summary>
/// Gets the group identifier.
/// </summary>
/// <value>The group identifier.</value>
public Guid GroupId { get; }
/// <summary>
/// Gets the group name.
/// </summary>
/// <value>The group name.</value>
public string GroupName { get; }
/// <summary>
/// Gets the group state.
/// </summary>
/// <value>The group state.</value>
public GroupStateType State { get; }
/// <summary>
/// Gets the participants.
/// </summary>
/// <value>The participants.</value>
public IReadOnlyList<string> Participants { get; }
/// <summary>
/// Gets the date when this DTO has been created.
/// </summary>
/// <value>The date when this DTO has been created.</value>
public DateTime LastUpdatedAt { get; }
}
}

View File

@@ -1,42 +0,0 @@
#nullable disable
using System.Collections.Generic;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class GroupInfoView.
/// </summary>
public class GroupInfoView
{
/// <summary>
/// Gets or sets the group identifier.
/// </summary>
/// <value>The group identifier.</value>
public string GroupId { get; set; }
/// <summary>
/// Gets or sets the playing item id.
/// </summary>
/// <value>The playing item id.</value>
public string PlayingItemId { get; set; }
/// <summary>
/// Gets or sets the playing item name.
/// </summary>
/// <value>The playing item name.</value>
public string PlayingItemName { get; set; }
/// <summary>
/// Gets or sets the position ticks.
/// </summary>
/// <value>The position ticks.</value>
public long PositionTicks { get; set; }
/// <summary>
/// Gets or sets the participants.
/// </summary>
/// <value>The participants.</value>
public IReadOnlyList<string> Participants { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum GroupQueueMode.
/// </summary>
public enum GroupQueueMode
{
/// <summary>
/// Insert items at the end of the queue.
/// </summary>
Queue = 0,
/// <summary>
/// Insert items after the currently playing item.
/// </summary>
QueueNext = 1
}
}

View File

@@ -0,0 +1,23 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum GroupRepeatMode.
/// </summary>
public enum GroupRepeatMode
{
/// <summary>
/// Repeat one item only.
/// </summary>
RepeatOne = 0,
/// <summary>
/// Cycle the playlist.
/// </summary>
RepeatAll = 1,
/// <summary>
/// Do not repeat.
/// </summary>
RepeatNone = 2
}
}

View File

@@ -0,0 +1,18 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum GroupShuffleMode.
/// </summary>
public enum GroupShuffleMode
{
/// <summary>
/// Sorted playlist.
/// </summary>
Sorted = 0,
/// <summary>
/// Shuffled playlist.
/// </summary>
Shuffle = 1
}
}

View File

@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum GroupState.
/// </summary>
public enum GroupStateType
{
/// <summary>
/// The group is in idle state. No media is playing.
/// </summary>
Idle = 0,
/// <summary>
/// The group is in wating state. Playback is paused. Will start playing when users are ready.
/// </summary>
Waiting = 1,
/// <summary>
/// The group is in paused state. Playback is paused. Will resume on play command.
/// </summary>
Paused = 2,
/// <summary>
/// The group is in playing state. Playback is advancing.
/// </summary>
Playing = 3
}
}

View File

@@ -0,0 +1,31 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class GroupStateUpdate.
/// </summary>
public class GroupStateUpdate
{
/// <summary>
/// Initializes a new instance of the <see cref="GroupStateUpdate"/> class.
/// </summary>
/// <param name="state">The state of the group.</param>
/// <param name="reason">The reason of the state change.</param>
public GroupStateUpdate(GroupStateType state, PlaybackRequestType reason)
{
State = state;
Reason = reason;
}
/// <summary>
/// Gets the state of the group.
/// </summary>
/// <value>The state of the group.</value>
public GroupStateType State { get; }
/// <summary>
/// Gets the reason of the state change.
/// </summary>
/// <value>The reason of the state change.</value>
public PlaybackRequestType Reason { get; }
}
}

View File

@@ -1,28 +1,42 @@
#nullable disable
using System;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class GroupUpdate.
/// </summary>
/// <typeparam name="T">The type of the data of the message.</typeparam>
public class GroupUpdate<T>
{
/// <summary>
/// Gets or sets the group identifier.
/// Initializes a new instance of the <see cref="GroupUpdate{T}"/> class.
/// </summary>
/// <param name="groupId">The group identifier.</param>
/// <param name="type">The update type.</param>
/// <param name="data">The update data.</param>
public GroupUpdate(Guid groupId, GroupUpdateType type, T data)
{
GroupId = groupId;
Type = type;
Data = data;
}
/// <summary>
/// Gets the group identifier.
/// </summary>
/// <value>The group identifier.</value>
public string GroupId { get; set; }
public Guid GroupId { get; }
/// <summary>
/// Gets or sets the update type.
/// Gets the update type.
/// </summary>
/// <value>The update type.</value>
public GroupUpdateType Type { get; set; }
public GroupUpdateType Type { get; }
/// <summary>
/// Gets or sets the data.
/// Gets the update data.
/// </summary>
/// <value>The data.</value>
public T Data { get; set; }
/// <value>The update data.</value>
public T Data { get; }
}
}

View File

@@ -26,14 +26,14 @@ namespace MediaBrowser.Model.SyncPlay
GroupLeft,
/// <summary>
/// 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.
/// </summary>
GroupWait,
StateUpdate,
/// <summary>
/// The prepare-session update. Tells a user to load some content.
/// The play-queue update. Tells a user the playing queue of the group.
/// </summary>
PrepareSession,
PlayQueue,
/// <summary>
/// The not-in-group error. Tells a user that they don't belong to a group.

View File

@@ -1,16 +0,0 @@
using System;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class JoinGroupRequest.
/// </summary>
public class JoinGroupRequest
{
/// <summary>
/// Gets or sets the Group id.
/// </summary>
/// <value>The Group id to join.</value>
public Guid GroupId { get; set; }
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class PlayQueueUpdate.
/// </summary>
public class PlayQueueUpdate
{
/// <summary>
/// Initializes a new instance of the <see cref="PlayQueueUpdate"/> class.
/// </summary>
/// <param name="reason">The reason for the update.</param>
/// <param name="lastUpdate">The UTC time of the last change to the playing queue.</param>
/// <param name="playlist">The playlist.</param>
/// <param name="playingItemIndex">The playing item index in the playlist.</param>
/// <param name="startPositionTicks">The start position ticks.</param>
/// <param name="shuffleMode">The shuffle mode.</param>
/// <param name="repeatMode">The repeat mode.</param>
public PlayQueueUpdate(PlayQueueUpdateReason reason, DateTime lastUpdate, IReadOnlyList<QueueItem> playlist, int playingItemIndex, long startPositionTicks, GroupShuffleMode shuffleMode, GroupRepeatMode repeatMode)
{
Reason = reason;
LastUpdate = lastUpdate;
Playlist = playlist;
PlayingItemIndex = playingItemIndex;
StartPositionTicks = startPositionTicks;
ShuffleMode = shuffleMode;
RepeatMode = repeatMode;
}
/// <summary>
/// Gets the request type that originated this update.
/// </summary>
/// <value>The reason for the update.</value>
public PlayQueueUpdateReason Reason { get; }
/// <summary>
/// Gets the UTC time of the last change to the playing queue.
/// </summary>
/// <value>The UTC time of the last change to the playing queue.</value>
public DateTime LastUpdate { get; }
/// <summary>
/// Gets the playlist.
/// </summary>
/// <value>The playlist.</value>
public IReadOnlyList<QueueItem> Playlist { get; }
/// <summary>
/// Gets the playing item index in the playlist.
/// </summary>
/// <value>The playing item index in the playlist.</value>
public int PlayingItemIndex { get; }
/// <summary>
/// Gets the start position ticks.
/// </summary>
/// <value>The start position ticks.</value>
public long StartPositionTicks { get; }
/// <summary>
/// Gets the shuffle mode.
/// </summary>
/// <value>The shuffle mode.</value>
public GroupShuffleMode ShuffleMode { get; }
/// <summary>
/// Gets the repeat mode.
/// </summary>
/// <value>The repeat mode.</value>
public GroupRepeatMode RepeatMode { get; }
}
}

View File

@@ -0,0 +1,58 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum PlayQueueUpdateReason.
/// </summary>
public enum PlayQueueUpdateReason
{
/// <summary>
/// A user is requesting to play a new playlist.
/// </summary>
NewPlaylist = 0,
/// <summary>
/// A user is changing the playing item.
/// </summary>
SetCurrentItem = 1,
/// <summary>
/// A user is removing items from the playlist.
/// </summary>
RemoveItems = 2,
/// <summary>
/// A user is moving an item in the playlist.
/// </summary>
MoveItem = 3,
/// <summary>
/// A user is adding items the queue.
/// </summary>
Queue = 4,
/// <summary>
/// A user is adding items to the queue, after the currently playing item.
/// </summary>
QueueNext = 5,
/// <summary>
/// A user is requesting the next item in queue.
/// </summary>
NextItem = 6,
/// <summary>
/// A user is requesting the previous item in queue.
/// </summary>
PreviousItem = 7,
/// <summary>
/// A user is changing repeat mode.
/// </summary>
RepeatMode = 8,
/// <summary>
/// A user is changing shuffle mode.
/// </summary>
ShuffleMode = 9
}
}

View File

@@ -1,34 +0,0 @@
using System;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class PlaybackRequest.
/// </summary>
public class PlaybackRequest
{
/// <summary>
/// Gets or sets the request type.
/// </summary>
/// <value>The request type.</value>
public PlaybackRequestType Type { get; set; }
/// <summary>
/// Gets or sets when the request has been made by the client.
/// </summary>
/// <value>The date of the request.</value>
public DateTime? When { get; set; }
/// <summary>
/// Gets or sets the position ticks.
/// </summary>
/// <value>The position ticks.</value>
public long? PositionTicks { get; set; }
/// <summary>
/// Gets or sets the ping time.
/// </summary>
/// <value>The ping time.</value>
public long? Ping { get; set; }
}
}

View File

@@ -6,33 +6,88 @@ namespace MediaBrowser.Model.SyncPlay
public enum PlaybackRequestType
{
/// <summary>
/// A user is requesting a play command for the group.
/// A user is setting a new playlist.
/// </summary>
Play = 0,
/// <summary>
/// A user is changing the playlist item.
/// </summary>
SetPlaylistItem = 1,
/// <summary>
/// A user is removing items from the playlist.
/// </summary>
RemoveFromPlaylist = 2,
/// <summary>
/// A user is moving an item in the playlist.
/// </summary>
MovePlaylistItem = 3,
/// <summary>
/// A user is adding items to the playlist.
/// </summary>
Queue = 4,
/// <summary>
/// A user is requesting an unpause command for the group.
/// </summary>
Unpause = 5,
/// <summary>
/// A user is requesting a pause command for the group.
/// </summary>
Pause = 1,
Pause = 6,
/// <summary>
/// A user is requesting a stop command for the group.
/// </summary>
Stop = 7,
/// <summary>
/// A user is requesting a seek command for the group.
/// </summary>
Seek = 2,
Seek = 8,
/// <summary>
/// <summary>
/// A user is signaling that playback is buffering.
/// </summary>
Buffer = 3,
Buffer = 9,
/// <summary>
/// A user is signaling that playback resumed.
/// </summary>
Ready = 4,
Ready = 10,
/// <summary>
/// A user is reporting its ping.
/// A user is requesting next item in playlist.
/// </summary>
Ping = 5
NextItem = 11,
/// <summary>
/// A user is requesting previous item in playlist.
/// </summary>
PreviousItem = 12,
/// <summary>
/// A user is setting the repeat mode.
/// </summary>
SetRepeatMode = 13,
/// <summary>
/// A user is setting the shuffle mode.
/// </summary>
SetShuffleMode = 14,
/// <summary>
/// A user is reporting their ping.
/// </summary>
Ping = 15,
/// <summary>
/// A user is requesting to be ignored on group wait.
/// </summary>
IgnoreWait = 16
}
}

View File

@@ -0,0 +1,31 @@
using System;
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Class QueueItem.
/// </summary>
public class QueueItem
{
/// <summary>
/// Initializes a new instance of the <see cref="QueueItem"/> class.
/// </summary>
/// <param name="itemId">The item identifier.</param>
public QueueItem(Guid itemId)
{
ItemId = itemId;
}
/// <summary>
/// Gets the item identifier.
/// </summary>
/// <value>The item identifier.</value>
public Guid ItemId { get; }
/// <summary>
/// Gets the playlist identifier of the item.
/// </summary>
/// <value>The playlist identifier of the item.</value>
public Guid PlaylistItemId { get; } = Guid.NewGuid();
}
}

View File

@@ -0,0 +1,33 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Enum RequestType.
/// </summary>
public enum RequestType
{
/// <summary>
/// A user is requesting to create a new group.
/// </summary>
NewGroup = 0,
/// <summary>
/// A user is requesting to join a group.
/// </summary>
JoinGroup = 1,
/// <summary>
/// A user is requesting to leave a group.
/// </summary>
LeaveGroup = 2,
/// <summary>
/// A user is requesting the list of available groups.
/// </summary>
ListGroups = 3,
/// <summary>
/// A user is sending a playback command to a group.
/// </summary>
Playback = 4
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
using System;
namespace MediaBrowser.Model.SyncPlay
{
@@ -8,33 +8,58 @@ namespace MediaBrowser.Model.SyncPlay
public class SendCommand
{
/// <summary>
/// Gets or sets the group identifier.
/// Initializes a new instance of the <see cref="SendCommand"/> class.
/// </summary>
/// <param name="groupId">The group identifier.</param>
/// <param name="playlistItemId">The playlist identifier of the playing item.</param>
/// <param name="when">The UTC time when to execute the command.</param>
/// <param name="command">The command.</param>
/// <param name="positionTicks">The position ticks, for commands that require it.</param>
/// <param name="emittedAt">The UTC time when this command has been emitted.</param>
public SendCommand(Guid groupId, Guid playlistItemId, DateTime when, SendCommandType command, long? positionTicks, DateTime emittedAt)
{
GroupId = groupId;
PlaylistItemId = playlistItemId;
When = when;
Command = command;
PositionTicks = positionTicks;
EmittedAt = emittedAt;
}
/// <summary>
/// Gets the group identifier.
/// </summary>
/// <value>The group identifier.</value>
public string GroupId { get; set; }
public Guid GroupId { get; }
/// <summary>
/// Gets the playlist identifier of the playing item.
/// </summary>
/// <value>The playlist identifier of the playing item.</value>
public Guid PlaylistItemId { get; }
/// <summary>
/// Gets or sets the UTC time when to execute the command.
/// </summary>
/// <value>The UTC time when to execute the command.</value>
public string When { get; set; }
public DateTime When { get; set; }
/// <summary>
/// Gets or sets the position ticks.
/// Gets the position ticks.
/// </summary>
/// <value>The position ticks.</value>
public long? PositionTicks { get; set; }
public long? PositionTicks { get; }
/// <summary>
/// Gets or sets the command.
/// Gets the command.
/// </summary>
/// <value>The command.</value>
public SendCommandType Command { get; set; }
public SendCommandType Command { get; }
/// <summary>
/// Gets or sets the UTC time when this command has been emitted.
/// Gets the UTC time when this command has been emitted.
/// </summary>
/// <value>The UTC time when this command has been emitted.</value>
public string EmittedAt { get; set; }
public DateTime EmittedAt { get; }
}
}

View File

@@ -6,18 +6,23 @@ namespace MediaBrowser.Model.SyncPlay
public enum SendCommandType
{
/// <summary>
/// The play command. Instructs users to start playback.
/// The unpause command. Instructs users to unpause playback.
/// </summary>
Play = 0,
Unpause = 0,
/// <summary>
/// The pause command. Instructs users to pause playback.
/// </summary>
Pause = 1,
/// <summary>
/// The stop command. Instructs users to stop playback.
/// </summary>
Stop = 2,
/// <summary>
/// The seek command. Instructs users to seek to a specified time.
/// </summary>
Seek = 2
Seek = 3
}
}

View File

@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.SyncPlay
{
/// <summary>
/// Used to filter the sessions of a group.
/// </summary>
public enum SyncPlayBroadcastType
{
/// <summary>
/// All sessions will receive the message.
/// </summary>
AllGroup = 0,
/// <summary>
/// Only the specified session will receive the message.
/// </summary>
CurrentSession = 1,
/// <summary>
/// All sessions, except the current one, will receive the message.
/// </summary>
AllExceptCurrentSession = 2,
/// <summary>
/// Only sessions that are not buffering will receive the message.
/// </summary>
AllReady = 3
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
using System;
namespace MediaBrowser.Model.SyncPlay
{
@@ -8,15 +8,26 @@ namespace MediaBrowser.Model.SyncPlay
public class UtcTimeResponse
{
/// <summary>
/// Gets or sets the UTC time when request has been received.
/// Initializes a new instance of the <see cref="UtcTimeResponse"/> class.
/// </summary>
/// <value>The UTC time when request has been received.</value>
public string RequestReceptionTime { get; set; }
/// <param name="requestReceptionTime">The UTC time when request has been received.</param>
/// <param name="responseTransmissionTime">The UTC time when response has been sent.</param>
public UtcTimeResponse(DateTime requestReceptionTime, DateTime responseTransmissionTime)
{
RequestReceptionTime = requestReceptionTime;
ResponseTransmissionTime = responseTransmissionTime;
}
/// <summary>
/// Gets or sets the UTC time when response has been sent.
/// Gets the UTC time when request has been received.
/// </summary>
/// <value>The UTC time when request has been received.</value>
public DateTime RequestReceptionTime { get; }
/// <summary>
/// Gets the UTC time when response has been sent.
/// </summary>
/// <value>The UTC time when response has been sent.</value>
public string ResponseTransmissionTime { get; set; }
public DateTime ResponseTransmissionTime { get; }
}
}