From 5d77f422f0e4998130f1defebd08e053188a1a25 Mon Sep 17 00:00:00 2001 From: Ionut Andrei Oanca Date: Sat, 14 Nov 2020 23:40:01 +0100 Subject: [PATCH] Hide some property setters, init null values, update namespaces --- .../SyncPlay/GroupController.cs | 49 +++------- .../Controllers/SyncPlayController.cs | 93 +++++-------------- .../GroupStates/AbstractGroupState.cs | 10 +- .../SyncPlay/GroupStates/IdleGroupState.cs | 3 +- .../SyncPlay/GroupStates/PausedGroupState.cs | 3 +- .../SyncPlay/GroupStates/PlayingGroupState.cs | 3 +- .../SyncPlay/GroupStates/WaitingGroupState.cs | 6 +- .../SyncPlay/IGroupController.cs | 1 + .../SyncPlay/IGroupState.cs | 1 + .../SyncPlay/IGroupStateContext.cs | 14 +-- .../PlaybackRequests/BufferGroupRequest.cs | 33 +++++-- .../IgnoreWaitGroupRequest.cs | 15 ++- .../MovePlaylistItemGroupRequest.cs | 23 +++-- .../PlaybackRequests/NextTrackGroupRequest.cs | 15 ++- .../PlaybackRequests/PauseGroupRequest.cs | 2 +- .../PlaybackRequests/PingGroupRequest.cs | 15 ++- .../PlaybackRequests/PlayGroupRequest.cs | 29 ++++-- .../PreviousTrackGroupRequest.cs | 15 ++- .../PlaybackRequests/QueueGroupRequest.cs | 27 ++++-- .../PlaybackRequests/ReadyGroupRequest.cs | 33 +++++-- .../RemoveFromPlaylistGroupRequest.cs | 15 ++- .../PlaybackRequests/SeekGroupRequest.cs | 15 ++- .../SetPlaylistItemGroupRequest.cs | 15 ++- .../SetRepeatModeGroupRequest.cs | 15 ++- .../SetShuffleModeGroupRequest.cs | 15 ++- .../PlaybackRequests/StopGroupRequest.cs | 2 +- .../PlaybackRequests/UnpauseGroupRequest.cs | 2 +- .../SyncPlay/Queue/PlayQueueManager.cs | 9 +- MediaBrowser.Model/SyncPlay/GroupInfoDto.cs | 15 ++- MediaBrowser.Model/SyncPlay/GroupQueueMode.cs | 18 ++++ .../SyncPlay/GroupRequestType.cs | 10 +- MediaBrowser.Model/SyncPlay/GroupStateType.cs | 8 +- .../SyncPlay/NewGroupRequest.cs | 10 +- .../SyncPlay/PlayQueueUpdate.cs | 13 ++- .../SyncPlay/PlayQueueUpdateReason.cs | 4 +- MediaBrowser.Model/SyncPlay/QueueItem.cs | 23 +++-- MediaBrowser.Model/SyncPlay/SendCommand.cs | 15 ++- 37 files changed, 365 insertions(+), 229 deletions(-) create mode 100644 MediaBrowser.Model/SyncPlay/GroupQueueMode.cs diff --git a/Emby.Server.Implementations/SyncPlay/GroupController.cs b/Emby.Server.Implementations/SyncPlay/GroupController.cs index 5447aad5dd..a0d951b3e6 100644 --- a/Emby.Server.Implementations/SyncPlay/GroupController.cs +++ b/Emby.Server.Implementations/SyncPlay/GroupController.cs @@ -10,6 +10,8 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Session; using MediaBrowser.Controller.SyncPlay; +using MediaBrowser.Controller.SyncPlay.GroupStates; +using MediaBrowser.Controller.SyncPlay.Queue; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; @@ -358,7 +360,7 @@ namespace Emby.Server.Implementations.SyncPlay GroupName = GroupName, State = _state.Type, Participants = Participants.Values.Select(session => session.Session.UserName).Distinct().ToList(), - LastUpdatedAt = DateToUTCString(DateTime.UtcNow) + LastUpdatedAt = DateTime.UtcNow }; } @@ -422,8 +424,8 @@ namespace Emby.Server.Implementations.SyncPlay PlaylistItemId = PlayQueue.GetPlayingItemPlaylistId(), PositionTicks = PositionTicks, Command = type, - When = DateToUTCString(LastActivity), - EmittedAt = DateToUTCString(DateTime.UtcNow) + When = LastActivity, + EmittedAt = DateTime.UtcNow }; } @@ -438,12 +440,6 @@ namespace Emby.Server.Implementations.SyncPlay }; } - /// - public string DateToUTCString(DateTime dateTime) - { - return dateTime.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture); - } - /// public long SanitizePositionTicks(long? positionTicks) { @@ -580,7 +576,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public bool AddToPlayQueue(IEnumerable newItems, string mode) + public bool AddToPlayQueue(IEnumerable newItems, GroupQueueMode mode) { // Ignore on empty list. if (!newItems.Any()) @@ -594,7 +590,7 @@ namespace Emby.Server.Implementations.SyncPlay return false; } - if (mode.Equals("next", StringComparison.OrdinalIgnoreCase)) + if (mode.Equals(GroupQueueMode.QueueNext)) { PlayQueue.QueueNext(newItems); } @@ -648,36 +644,15 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public void SetRepeatMode(string mode) + public void SetRepeatMode(GroupRepeatMode mode) { - switch (mode) - { - case "RepeatOne": - PlayQueue.SetRepeatMode(GroupRepeatMode.RepeatOne); - break; - case "RepeatAll": - PlayQueue.SetRepeatMode(GroupRepeatMode.RepeatAll); - break; - default: - // On unknown values, default to repeat none. - PlayQueue.SetRepeatMode(GroupRepeatMode.RepeatNone); - break; - } + PlayQueue.SetRepeatMode(mode); } /// - public void SetShuffleMode(string mode) + public void SetShuffleMode(GroupShuffleMode mode) { - switch (mode) - { - case "Shuffle": - PlayQueue.SetShuffleMode(GroupShuffleMode.Shuffle); - break; - default: - // On unknown values, default to sorted playlist. - PlayQueue.SetShuffleMode(GroupShuffleMode.Sorted); - break; - } + PlayQueue.SetShuffleMode(mode); } /// @@ -701,7 +676,7 @@ namespace Emby.Server.Implementations.SyncPlay return new PlayQueueUpdate() { Reason = reason, - LastUpdate = DateToUTCString(PlayQueue.LastChange), + LastUpdate = PlayQueue.LastChange, Playlist = PlayQueue.GetPlaylist(), PlayingItemIndex = PlayQueue.PlayingItemIndex, StartPositionTicks = startPositionTicks, diff --git a/Jellyfin.Api/Controllers/SyncPlayController.cs b/Jellyfin.Api/Controllers/SyncPlayController.cs index 6bd78179b5..9085a71c88 100644 --- a/Jellyfin.Api/Controllers/SyncPlayController.cs +++ b/Jellyfin.Api/Controllers/SyncPlayController.cs @@ -7,6 +7,7 @@ using Jellyfin.Api.Helpers; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Controller.SyncPlay; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -118,17 +119,12 @@ namespace Jellyfin.Api.Controllers [HttpPost("Play")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayPlay( - [FromQuery, Required] string playingQueue, + [FromQuery, Required] Guid[] playingQueue, [FromQuery, Required] int playingItemPosition, [FromQuery, Required] long startPositionTicks) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PlayGroupRequest() - { - PlayingItemPosition = playingItemPosition, - StartPositionTicks = startPositionTicks - }; - syncPlayRequest.PlayingQueue.AddRange(RequestHelpers.GetGuids(playingQueue)); + var syncPlayRequest = new PlayGroupRequest(playingQueue, playingItemPosition, startPositionTicks); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -145,10 +141,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] string playlistItemId) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetPlaylistItemGroupRequest() - { - PlaylistItemId = playlistItemId - }; + var syncPlayRequest = new SetPlaylistItemGroupRequest(playlistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -165,8 +158,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] string[] playlistItemIds) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new RemoveFromPlaylistGroupRequest(); - syncPlayRequest.PlaylistItemIds.AddRange(playlistItemIds); + var syncPlayRequest = new RemoveFromPlaylistGroupRequest(playlistItemIds); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -185,11 +177,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] int newIndex) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new MovePlaylistItemGroupRequest() - { - PlaylistItemId = playlistItemId, - NewIndex = newIndex - }; + var syncPlayRequest = new MovePlaylistItemGroupRequest(playlistItemId, newIndex); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -197,22 +185,18 @@ namespace Jellyfin.Api.Controllers /// /// Request to queue items to the playlist of a SyncPlay group. /// - /// The items to add. Item ids, comma delimited. - /// The mode in which to queue items. + /// The items to add. + /// The mode in which to enqueue the items. /// Queue update request sent to all group members. /// A indicating success. [HttpPost("Queue")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlayQueue( - [FromQuery, Required] string itemIds, - [FromQuery, Required] string mode) + [FromQuery, Required] Guid[] items, + [FromQuery, Required] GroupQueueMode mode) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new QueueGroupRequest() - { - Mode = mode - }; - syncPlayRequest.ItemIds.AddRange(RequestHelpers.GetGuids(itemIds)); + var syncPlayRequest = new QueueGroupRequest(items, mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -274,10 +258,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] long positionTicks) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SeekGroupRequest() - { - PositionTicks = positionTicks - }; + var syncPlayRequest = new SeekGroupRequest(positionTicks); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -305,23 +286,11 @@ namespace Jellyfin.Api.Controllers IGroupPlaybackRequest syncPlayRequest; if (!bufferingDone) { - syncPlayRequest = new BufferGroupRequest() - { - When = when, - PositionTicks = positionTicks, - IsPlaying = isPlaying, - PlaylistItemId = playlistItemId - }; + syncPlayRequest = new BufferGroupRequest(when, positionTicks, isPlaying, playlistItemId); } else { - syncPlayRequest = new ReadyGroupRequest() - { - When = when, - PositionTicks = positionTicks, - IsPlaying = isPlaying, - PlaylistItemId = playlistItemId - }; + syncPlayRequest = new ReadyGroupRequest(when, positionTicks, isPlaying, playlistItemId); } _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); @@ -340,10 +309,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] bool ignoreWait) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new IgnoreWaitGroupRequest() - { - IgnoreWait = ignoreWait - }; + var syncPlayRequest = new IgnoreWaitGroupRequest(ignoreWait); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -360,10 +326,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] string playlistItemId) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new NextTrackGroupRequest() - { - PlaylistItemId = playlistItemId - }; + var syncPlayRequest = new NextTrackGroupRequest(playlistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -380,10 +343,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] string playlistItemId) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PreviousTrackGroupRequest() - { - PlaylistItemId = playlistItemId - }; + var syncPlayRequest = new PreviousTrackGroupRequest(playlistItemId); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -397,13 +357,10 @@ namespace Jellyfin.Api.Controllers [HttpPost("SetRepeatMode")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetRepeatMode( - [FromQuery, Required] string mode) + [FromQuery, Required] GroupRepeatMode mode) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetRepeatModeGroupRequest() - { - Mode = mode - }; + var syncPlayRequest = new SetRepeatModeGroupRequest(mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -417,13 +374,10 @@ namespace Jellyfin.Api.Controllers [HttpPost("SetShuffleMode")] [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult SyncPlaySetShuffleMode( - [FromQuery, Required] string mode) + [FromQuery, Required] GroupShuffleMode mode) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new SetShuffleModeGroupRequest() - { - Mode = mode - }; + var syncPlayRequest = new SetShuffleModeGroupRequest(mode); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } @@ -440,10 +394,7 @@ namespace Jellyfin.Api.Controllers [FromQuery, Required] double ping) { var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request); - var syncPlayRequest = new PingGroupRequest() - { - Ping = Convert.ToInt64(ping) - }; + var syncPlayRequest = new PingGroupRequest(Convert.ToInt64(ping)); _syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None); return NoContent(); } diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/AbstractGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/AbstractGroupState.cs index 829ef2bbab..bc2e223802 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/AbstractGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/AbstractGroupState.cs @@ -1,10 +1,10 @@ -using System; using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.GroupStates { /// /// Class AbstractGroupState. @@ -104,7 +104,11 @@ namespace MediaBrowser.Controller.SyncPlay return; } - var reason = request.Mode.Equals("next", StringComparison.OrdinalIgnoreCase) ? PlayQueueUpdateReason.QueueNext : PlayQueueUpdateReason.Queue; + var reason = request.Mode switch + { + GroupQueueMode.QueueNext => PlayQueueUpdateReason.QueueNext, + _ => PlayQueueUpdateReason.Queue + }; var playQueueUpdate = context.GetPlayQueueUpdate(reason); var update = context.NewSyncPlayGroupUpdate(GroupUpdateType.PlayQueue, playQueueUpdate); context.SendGroupUpdate(session, SyncPlayBroadcastType.AllGroup, update, cancellationToken); diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/IdleGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/IdleGroupState.cs index d9350cc9b9..660afb607d 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/IdleGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/IdleGroupState.cs @@ -1,9 +1,10 @@ using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.GroupStates { /// /// Class IdleGroupState. diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/PausedGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/PausedGroupState.cs index 5ae4786057..29942898e6 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/PausedGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/PausedGroupState.cs @@ -1,10 +1,11 @@ using System; using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.GroupStates { /// /// Class PausedGroupState. diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/PlayingGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/PlayingGroupState.cs index 394c64e511..c5d73dedb8 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/PlayingGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/PlayingGroupState.cs @@ -1,10 +1,11 @@ using System; using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.GroupStates { /// /// Class PlayingGroupState. diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs index c78077b357..78318dd94d 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs @@ -1,10 +1,11 @@ using System; using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; using Microsoft.Extensions.Logging; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.GroupStates { /// /// Class WaitingGroupState. @@ -464,8 +465,7 @@ namespace MediaBrowser.Controller.SyncPlay { // Others are still buffering, tell this client to pause when ready. var command = context.NewSyncPlayCommand(SendCommandType.Pause); - var pauseAtTime = currentTime.AddTicks(delayTicks); - command.When = context.DateToUTCString(pauseAtTime); + command.When = currentTime.AddTicks(delayTicks); context.SendCommand(session, SyncPlayBroadcastType.CurrentSession, command, cancellationToken); Logger.LogInformation("HandleRequest: {0} in group {1}, others still buffering, {2} will pause when ready in {3} seconds.", request.Type, context.GroupId.ToString(), session.Id, TimeSpan.FromTicks(delayTicks).TotalSeconds); diff --git a/MediaBrowser.Controller/SyncPlay/IGroupController.cs b/MediaBrowser.Controller/SyncPlay/IGroupController.cs index 038233fdd3..aa8bb9eaea 100644 --- a/MediaBrowser.Controller/SyncPlay/IGroupController.cs +++ b/MediaBrowser.Controller/SyncPlay/IGroupController.cs @@ -2,6 +2,7 @@ using System; using System.Threading; using Jellyfin.Data.Entities; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.Queue; using MediaBrowser.Model.SyncPlay; namespace MediaBrowser.Controller.SyncPlay diff --git a/MediaBrowser.Controller/SyncPlay/IGroupState.cs b/MediaBrowser.Controller/SyncPlay/IGroupState.cs index f6ebe2a58d..0028823b4e 100644 --- a/MediaBrowser.Controller/SyncPlay/IGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/IGroupState.cs @@ -1,5 +1,6 @@ using System.Threading; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.PlaybackRequests; using MediaBrowser.Model.SyncPlay; namespace MediaBrowser.Controller.SyncPlay diff --git a/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs b/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs index 2ddaae6400..3609be36b7 100644 --- a/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs +++ b/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.SyncPlay.Queue; using MediaBrowser.Model.SyncPlay; namespace MediaBrowser.Controller.SyncPlay @@ -97,13 +98,6 @@ namespace MediaBrowser.Controller.SyncPlay /// The group update. GroupUpdate NewSyncPlayGroupUpdate(GroupUpdateType type, T data); - /// - /// Converts DateTime to UTC string. - /// - /// The date to convert. - /// The UTC string. - string DateToUTCString(DateTime dateTime); - /// /// Sanitizes the PositionTicks, considers the current playing item when available. /// @@ -187,7 +181,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The new items to add to the play queue. /// The mode with which the items will be added. /// true if the play queue has been changed; false if something went wrong. - bool AddToPlayQueue(IEnumerable newItems, string mode); + bool AddToPlayQueue(IEnumerable newItems, GroupQueueMode mode); /// /// Restarts current item in play queue. @@ -210,13 +204,13 @@ namespace MediaBrowser.Controller.SyncPlay /// Sets the repeat mode. /// /// The new mode. - void SetRepeatMode(string mode); + void SetRepeatMode(GroupRepeatMode mode); /// /// Sets the shuffle mode. /// /// The new mode. - void SetShuffleMode(string mode); + void SetShuffleMode(GroupShuffleMode mode); /// /// Creates a play queue update. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs index b5bed89f21..a12ab96b77 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs @@ -3,7 +3,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class BufferGroupRequest. @@ -11,28 +11,43 @@ namespace MediaBrowser.Controller.SyncPlay public class BufferGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets when the request has been made by the client. + /// Initializes a new instance of the class. + /// + /// When the request has been made, as reported by the client. + /// The position ticks. + /// Whether the client playback is unpaused. + /// The playlist item identifier of the playing item. + public BufferGroupRequest(DateTime when, long positionTicks, bool isPlaying, string playlistItemId) + { + When = when; + PositionTicks = positionTicks; + IsPlaying = isPlaying; + PlaylistItemId = playlistItemId; + } + + /// + /// Gets when the request has been made by the client. /// /// The date of the request. - public DateTime When { get; set; } + public DateTime When { get; } /// - /// Gets or sets the position ticks. + /// Gets the position ticks. /// /// The position ticks. - public long PositionTicks { get; set; } + public long PositionTicks { get; } /// - /// Gets or sets a value indicating whether the client playback is unpaused. + /// Gets a value indicating whether the client playback is unpaused. /// /// The client playback status. - public bool IsPlaying { get; set; } + public bool IsPlaying { get; } /// - /// Gets or sets the playlist item identifier of the playing item. + /// Gets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Buffer; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/IgnoreWaitGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/IgnoreWaitGroupRequest.cs index 325839f107..25034cb10b 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/IgnoreWaitGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/IgnoreWaitGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class IgnoreWaitGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class IgnoreWaitGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets a value indicating whether the client should be ignored. + /// Initializes a new instance of the class. + /// + /// Whether the client should be ignored. + public IgnoreWaitGroupRequest(bool ignoreWait) + { + IgnoreWait = ignoreWait; + } + + /// + /// Gets a value indicating whether the client should be ignored. /// /// The client group-wait status. - public bool IgnoreWait { get; set; } + public bool IgnoreWait { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.IgnoreWait; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs index 3c95f53d4a..a12eff8b84 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class MovePlaylistItemGroupRequest. @@ -10,16 +10,27 @@ namespace MediaBrowser.Controller.SyncPlay public class MovePlaylistItemGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the playlist identifier of the item. + /// Initializes a new instance of the class. /// - /// The playlist identifier of the item. - public string PlaylistItemId { get; set; } + /// The playlist identifier of the item. + /// The new position. + public MovePlaylistItemGroupRequest(string playlistItemId, int newIndex) + { + PlaylistItemId = playlistItemId; + NewIndex = newIndex; + } /// - /// Gets or sets the new position. + /// Gets the playlist identifier of the item. + /// + /// The playlist identifier of the item. + public string PlaylistItemId { get; } + + /// + /// Gets the new position. /// /// The new position. - public int NewIndex { get; set; } + public int NewIndex { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.MovePlaylistItem; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextTrackGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextTrackGroupRequest.cs index 8636d6f4d5..f87bbc556d 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextTrackGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextTrackGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class NextTrackGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class NextTrackGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the playing item identifier. + /// Initializes a new instance of the class. + /// + /// The playing item identifier. + public NextTrackGroupRequest(string playlistItemId) + { + PlaylistItemId = playlistItemId; + } + + /// + /// Gets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.NextTrack; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PauseGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PauseGroupRequest.cs index 45bd3b15f1..0dcd1423fd 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PauseGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PauseGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class PauseGroupRequest. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PingGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PingGroupRequest.cs index 9dacb79857..2528bb3e70 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PingGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PingGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class PingGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class PingGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the ping time. + /// Initializes a new instance of the class. + /// + /// The ping time. + public PingGroupRequest(long ping) + { + Ping = ping; + } + + /// + /// Gets the ping time. /// /// The ping time. - public long Ping { get; set; } + public long Ping { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Ping; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs index e090a882e2..306c161ed9 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PlayGroupRequest.cs @@ -4,30 +4,45 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class PlayGroupRequest. /// public class PlayGroupRequest : IGroupPlaybackRequest { + /// + /// Initializes a new instance of the class. + /// + /// The playing queue. + /// The playing item position. + /// The start position ticks. + public PlayGroupRequest(Guid[] playingQueue, int playingItemPosition, long startPositionTicks) + { + var list = new List(); + list.AddRange(playingQueue); + PlayingQueue = list; + PlayingItemPosition = playingItemPosition; + StartPositionTicks = startPositionTicks; + } + /// /// Gets the playing queue. /// /// The playing queue. - public List PlayingQueue { get; } = new List(); + public IReadOnlyList PlayingQueue { get; } /// - /// Gets or sets the playing item from the queue. + /// Gets the position of the playing item in the queue. /// - /// The playing item. - public int PlayingItemPosition { get; set; } + /// The playing item position. + public int PlayingItemPosition { get; } /// - /// Gets or sets the start position ticks. + /// Gets the start position ticks. /// /// The start position ticks. - public long StartPositionTicks { get; set; } + public long StartPositionTicks { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Play; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousTrackGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousTrackGroupRequest.cs index aca5d678e0..206fef3312 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousTrackGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousTrackGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class PreviousTrackGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class PreviousTrackGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the playing item identifier. + /// Initializes a new instance of the class. + /// + /// The playing item identifier. + public PreviousTrackGroupRequest(string playlistItemId) + { + PlaylistItemId = playlistItemId; + } + + /// + /// Gets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.PreviousTrack; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs index 82380b2098..9580b53154 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/QueueGroupRequest.cs @@ -4,7 +4,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class QueueGroupRequest. @@ -12,16 +12,29 @@ namespace MediaBrowser.Controller.SyncPlay public class QueueGroupRequest : IGroupPlaybackRequest { /// - /// Gets the items to queue. + /// Initializes a new instance of the class. /// - /// The items to queue. - public List ItemIds { get; } = new List(); + /// The items to add to the queue. + /// The enqueue mode. + public QueueGroupRequest(Guid[] items, GroupQueueMode mode) + { + var list = new List(); + list.AddRange(items); + ItemIds = list; + Mode = mode; + } /// - /// Gets or sets the mode in which to add the new items. + /// Gets the items to enqueue. /// - /// The mode. - public string Mode { get; set; } + /// The items to enqueue. + public IReadOnlyList ItemIds { get; } + + /// + /// Gets the mode in which to add the new items. + /// + /// The enqueue mode. + public GroupQueueMode Mode { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Queue; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs index c8a2268cfb..a2b3553cee 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs @@ -3,7 +3,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class ReadyGroupRequest. @@ -11,28 +11,43 @@ namespace MediaBrowser.Controller.SyncPlay public class ReadyGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets when the request has been made by the client. + /// Initializes a new instance of the class. + /// + /// When the request has been made, as reported by the client. + /// The position ticks. + /// Whether the client playback is unpaused. + /// The playlist item identifier of the playing item. + public ReadyGroupRequest(DateTime when, long positionTicks, bool isPlaying, string playlistItemId) + { + When = when; + PositionTicks = positionTicks; + IsPlaying = isPlaying; + PlaylistItemId = playlistItemId; + } + + /// + /// Gets when the request has been made by the client. /// /// The date of the request. - public DateTime When { get; set; } + public DateTime When { get; } /// - /// Gets or sets the position ticks. + /// Gets the position ticks. /// /// The position ticks. - public long PositionTicks { get; set; } + public long PositionTicks { get; } /// - /// Gets or sets a value indicating whether the client playback is unpaused. + /// Gets a value indicating whether the client playback is unpaused. /// /// The client playback status. - public bool IsPlaying { get; set; } + public bool IsPlaying { get; } /// - /// Gets or sets the playlist item identifier of the playing item. + /// Gets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Ready; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs index 4ead1301b6..21c602846e 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs @@ -3,18 +3,29 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class RemoveFromPlaylistGroupRequest. /// public class RemoveFromPlaylistGroupRequest : IGroupPlaybackRequest { + /// + /// Initializes a new instance of the class. + /// + /// The playlist ids of the items to remove. + public RemoveFromPlaylistGroupRequest(string[] items) + { + var list = new List(); + list.AddRange(items); + PlaylistItemIds = list; + } + /// /// Gets the playlist identifiers ot the items. /// /// The playlist identifiers ot the items. - public List PlaylistItemIds { get; } = new List(); + public IReadOnlyList PlaylistItemIds { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.RemoveFromPlaylist; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SeekGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SeekGroupRequest.cs index d311bffdc4..f7bfc19788 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SeekGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SeekGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class SeekGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class SeekGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the position ticks. + /// Initializes a new instance of the class. + /// + /// The position ticks. + public SeekGroupRequest(long positionTicks) + { + PositionTicks = positionTicks; + } + + /// + /// Gets the position ticks. /// /// The position ticks. - public long PositionTicks { get; set; } + public long PositionTicks { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.Seek; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs index 0983d91292..2ca33c1ccf 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class SetPlaylistItemGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class SetPlaylistItemGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the playlist identifier of the playing item. + /// Initializes a new instance of the class. + /// + /// The playlist identifier of the item. + public SetPlaylistItemGroupRequest(string playlistItemId) + { + PlaylistItemId = playlistItemId; + } + + /// + /// Gets the playlist identifier of the playing item. /// /// The playlist identifier of the playing item. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.SetPlaylistItem; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetRepeatModeGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetRepeatModeGroupRequest.cs index 79373ef5f5..cd4505e4d0 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetRepeatModeGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetRepeatModeGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class SetRepeatModeGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class SetRepeatModeGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the repeat mode. + /// Initializes a new instance of the class. + /// + /// The repeat mode. + public SetRepeatModeGroupRequest(GroupRepeatMode mode) + { + Mode = mode; + } + + /// + /// Gets the repeat mode. /// /// The repeat mode. - public string Mode { get; set; } + public GroupRepeatMode Mode { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.SetRepeatMode; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetShuffleModeGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetShuffleModeGroupRequest.cs index 316fb49f40..4530a34c02 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetShuffleModeGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetShuffleModeGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class SetShuffleModeGroupRequest. @@ -10,10 +10,19 @@ namespace MediaBrowser.Controller.SyncPlay public class SetShuffleModeGroupRequest : IGroupPlaybackRequest { /// - /// Gets or sets the shuffle mode. + /// Initializes a new instance of the class. + /// + /// The shuffle mode. + public SetShuffleModeGroupRequest(GroupShuffleMode mode) + { + Mode = mode; + } + + /// + /// Gets the shuffle mode. /// /// The shuffle mode. - public string Mode { get; set; } + public GroupShuffleMode Mode { get; } /// public PlaybackRequestType Type { get; } = PlaybackRequestType.SetShuffleMode; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/StopGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/StopGroupRequest.cs index 9f6f8ea63c..ec01cd1105 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/StopGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/StopGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class StopGroupRequest. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/UnpauseGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/UnpauseGroupRequest.cs index 84a6b0a6e7..bdf4fd4767 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/UnpauseGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/UnpauseGroupRequest.cs @@ -2,7 +2,7 @@ using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests { /// /// Class UnpauseGroupRequest. diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs index 821a6314bd..2d1d1533b9 100644 --- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs +++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.SyncPlay; -namespace MediaBrowser.Controller.SyncPlay +namespace MediaBrowser.Controller.SyncPlay.Queue { /// /// Class PlayQueueManager. @@ -563,11 +563,8 @@ namespace MediaBrowser.Controller.SyncPlay var list = new List(); foreach (var item in items) { - list.Add(new QueueItem() - { - ItemId = item, - PlaylistItemId = "syncPlayItem" + GetNextProgressiveId() - }); + var queueItem = new QueueItem(item, "syncPlayItem" + GetNextProgressiveId()); + list.Add(queueItem); } return list; diff --git a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs index 85b9a35229..16a75eb68e 100644 --- a/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs +++ b/MediaBrowser.Model/SyncPlay/GroupInfoDto.cs @@ -1,5 +1,4 @@ -#nullable disable - +using System; using System.Collections.Generic; namespace MediaBrowser.Model.SyncPlay @@ -9,6 +8,16 @@ namespace MediaBrowser.Model.SyncPlay /// public class GroupInfoDto { + /// + /// Initializes a new instance of the class. + /// + public GroupInfoDto() + { + GroupId = string.Empty; + GroupName = string.Empty; + Participants = new List(); + } + /// /// Gets or sets the group identifier. /// @@ -37,6 +46,6 @@ namespace MediaBrowser.Model.SyncPlay /// Gets or sets the date when this dto has been updated. /// /// The date when this dto has been updated. - public string LastUpdatedAt { get; set; } + public DateTime LastUpdatedAt { get; set; } } } diff --git a/MediaBrowser.Model/SyncPlay/GroupQueueMode.cs b/MediaBrowser.Model/SyncPlay/GroupQueueMode.cs new file mode 100644 index 0000000000..5c9c2627b9 --- /dev/null +++ b/MediaBrowser.Model/SyncPlay/GroupQueueMode.cs @@ -0,0 +1,18 @@ +namespace MediaBrowser.Model.SyncPlay +{ + /// + /// Enum GroupQueueMode. + /// + public enum GroupQueueMode + { + /// + /// Insert items at the end of the queue. + /// + Queue = 0, + + /// + /// Insert items after the currently playing item. + /// + QueueNext = 1 + } +} diff --git a/MediaBrowser.Model/SyncPlay/GroupRequestType.cs b/MediaBrowser.Model/SyncPlay/GroupRequestType.cs index e7361817ca..75c0712364 100644 --- a/MediaBrowser.Model/SyncPlay/GroupRequestType.cs +++ b/MediaBrowser.Model/SyncPlay/GroupRequestType.cs @@ -8,26 +8,26 @@ namespace MediaBrowser.Model.SyncPlay /// /// A user is requesting to create a new group. /// - NewGroup, + NewGroup = 0, /// /// A user is requesting to join a group. /// - JoinGroup, + JoinGroup = 1, /// /// A user is requesting to leave a group. /// - LeaveGroup, + LeaveGroup = 2, /// /// A user is requesting the list of available groups. /// - ListGroups, + ListGroups = 3, /// /// A user is sending a playback command to a group. /// - Playback + Playback = 4 } } diff --git a/MediaBrowser.Model/SyncPlay/GroupStateType.cs b/MediaBrowser.Model/SyncPlay/GroupStateType.cs index 341859b306..7aa454f928 100644 --- a/MediaBrowser.Model/SyncPlay/GroupStateType.cs +++ b/MediaBrowser.Model/SyncPlay/GroupStateType.cs @@ -8,21 +8,21 @@ namespace MediaBrowser.Model.SyncPlay /// /// The group is in idle state. No media is playing. /// - Idle, + Idle = 0, /// /// The group is in wating state. Playback is paused. Will start playing when users are ready. /// - Waiting, + Waiting = 1, /// /// The group is in paused state. Playback is paused. Will resume on play command. /// - Paused, + Paused = 2, /// /// The group is in playing state. Playback is advancing. /// - Playing + Playing = 3 } } diff --git a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs index ccab5313f7..eb61a68d15 100644 --- a/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs +++ b/MediaBrowser.Model/SyncPlay/NewGroupRequest.cs @@ -1,5 +1,3 @@ -#nullable disable - namespace MediaBrowser.Model.SyncPlay { /// @@ -7,6 +5,14 @@ namespace MediaBrowser.Model.SyncPlay /// public class NewGroupRequest { + /// + /// Initializes a new instance of the class. + /// + public NewGroupRequest() + { + GroupName = string.Empty; + } + /// /// Gets or sets the group name. /// diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs index 575597e62d..d193b4c663 100644 --- a/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdate.cs @@ -1,5 +1,4 @@ -#nullable disable - +using System; using System.Collections.Generic; namespace MediaBrowser.Model.SyncPlay @@ -9,6 +8,14 @@ namespace MediaBrowser.Model.SyncPlay /// public class PlayQueueUpdate { + /// + /// Initializes a new instance of the class. + /// + public PlayQueueUpdate() + { + Playlist = new List(); + } + /// /// Gets or sets the request type that originated this update. /// @@ -19,7 +26,7 @@ namespace MediaBrowser.Model.SyncPlay /// 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; } + public DateTime LastUpdate { get; set; } /// /// Gets or sets the playlist. diff --git a/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs b/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs index 4b3f6eb4d6..e78940fe68 100644 --- a/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs +++ b/MediaBrowser.Model/SyncPlay/PlayQueueUpdateReason.cs @@ -26,12 +26,12 @@ namespace MediaBrowser.Model.SyncPlay MoveItem = 3, /// - /// A user is making changes to the queue. + /// A user is adding items the queue. /// Queue = 4, /// - /// A user is making changes to the queue. + /// A user is adding items to the queue, after the currently playing item. /// QueueNext = 5, diff --git a/MediaBrowser.Model/SyncPlay/QueueItem.cs b/MediaBrowser.Model/SyncPlay/QueueItem.cs index ce253b182c..9c4d3a4ceb 100644 --- a/MediaBrowser.Model/SyncPlay/QueueItem.cs +++ b/MediaBrowser.Model/SyncPlay/QueueItem.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; namespace MediaBrowser.Model.SyncPlay @@ -10,15 +8,26 @@ namespace MediaBrowser.Model.SyncPlay public class QueueItem { /// - /// Gets or sets the item identifier. + /// Initializes a new instance of the class. /// - /// The item identifier. - public Guid ItemId { get; set; } + /// The item identifier. + /// The playlist identifier of the item. + public QueueItem(Guid itemId, string playlistItemId) + { + ItemId = itemId; + PlaylistItemId = playlistItemId; + } /// - /// Gets or sets the playlist identifier of the item. + /// Gets the item identifier. + /// + /// The item identifier. + public Guid ItemId { get; } + + /// + /// Gets the playlist identifier of the item. /// /// The playlist identifier of the item. - public string PlaylistItemId { get; set; } + public string PlaylistItemId { get; } } } diff --git a/MediaBrowser.Model/SyncPlay/SendCommand.cs b/MediaBrowser.Model/SyncPlay/SendCommand.cs index b24f7e97bd..a3aa54b380 100644 --- a/MediaBrowser.Model/SyncPlay/SendCommand.cs +++ b/MediaBrowser.Model/SyncPlay/SendCommand.cs @@ -1,4 +1,4 @@ -#nullable disable +using System; namespace MediaBrowser.Model.SyncPlay { @@ -7,6 +7,15 @@ namespace MediaBrowser.Model.SyncPlay /// public class SendCommand { + /// + /// Initializes a new instance of the class. + /// + public SendCommand() + { + GroupId = string.Empty; + PlaylistItemId = string.Empty; + } + /// /// Gets or sets the group identifier. /// @@ -23,7 +32,7 @@ namespace MediaBrowser.Model.SyncPlay /// Gets or sets the UTC time when to execute the command. /// /// The UTC time when to execute the command. - public string When { get; set; } + public DateTime When { get; set; } /// /// Gets or sets the position ticks. @@ -41,6 +50,6 @@ namespace MediaBrowser.Model.SyncPlay /// Gets or sets the UTC time when this command has been emitted. /// /// The UTC time when this command has been emitted. - public string EmittedAt { get; set; } + public DateTime EmittedAt { get; set; } } }