From cbf70e7a037f9edb431cf0e0f43b261b9a1cf203 Mon Sep 17 00:00:00 2001 From: Ionut Andrei Oanca Date: Fri, 4 Dec 2020 20:15:16 +0100 Subject: [PATCH] Change type of PlaylistItemId to Guid --- Emby.Server.Implementations/SyncPlay/Group.cs | 6 ++-- .../Models/SyncPlayDtos/BufferRequestDto.cs | 4 +-- .../MovePlaylistItemRequestDto.cs | 6 ++-- .../Models/SyncPlayDtos/NextItemRequestDto.cs | 6 ++-- .../SyncPlayDtos/PreviousItemRequestDto.cs | 6 ++-- .../Models/SyncPlayDtos/ReadyRequestDto.cs | 4 +-- .../RemoveFromPlaylistRequestDto.cs | 4 +-- .../SyncPlayDtos/SetPlaylistItemRequestDto.cs | 6 ++-- .../SyncPlay/GroupStates/WaitingGroupState.cs | 8 ++--- .../SyncPlay/IGroupStateContext.cs | 6 ++-- .../PlaybackRequests/BufferGroupRequest.cs | 4 +-- .../MovePlaylistItemGroupRequest.cs | 5 +-- .../PlaybackRequests/NextItemGroupRequest.cs | 5 +-- .../PreviousItemGroupRequest.cs | 5 +-- .../PlaybackRequests/ReadyGroupRequest.cs | 4 +-- .../RemoveFromPlaylistGroupRequest.cs | 6 ++-- .../SetPlaylistItemGroupRequest.cs | 5 +-- .../SyncPlay/Queue/PlayQueueManager.cs | 32 +++++-------------- MediaBrowser.Model/SyncPlay/QueueItem.cs | 6 ++-- MediaBrowser.Model/SyncPlay/SendCommand.cs | 4 +-- 20 files changed, 63 insertions(+), 69 deletions(-) diff --git a/Emby.Server.Implementations/SyncPlay/Group.cs b/Emby.Server.Implementations/SyncPlay/Group.cs index e32f5e25d..b5031b708 100644 --- a/Emby.Server.Implementations/SyncPlay/Group.cs +++ b/Emby.Server.Implementations/SyncPlay/Group.cs @@ -505,7 +505,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public bool SetPlayingItem(string playlistItemId) + public bool SetPlayingItem(Guid playlistItemId) { var itemFound = PlayQueue.SetPlayingItemByPlaylistId(playlistItemId); @@ -525,7 +525,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public bool RemoveFromPlayQueue(IReadOnlyList playlistItemIds) + public bool RemoveFromPlayQueue(IReadOnlyList playlistItemIds) { var playingItemRemoved = PlayQueue.RemoveFromPlaylist(playlistItemIds); if (playingItemRemoved) @@ -548,7 +548,7 @@ namespace Emby.Server.Implementations.SyncPlay } /// - public bool MoveItemInPlayQueue(string playlistItemId, int newIndex) + public bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex) { return PlayQueue.MovePlaylistItem(playlistItemId, newIndex); } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/BufferRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/BufferRequestDto.cs index cafc400c9..479c44084 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/BufferRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/BufferRequestDto.cs @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public BufferRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// @@ -37,6 +37,6 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// Gets or sets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } } } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/MovePlaylistItemRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/MovePlaylistItemRequestDto.cs index 9e9c0b1ea..3af25f3e3 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/MovePlaylistItemRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/MovePlaylistItemRequestDto.cs @@ -1,3 +1,5 @@ +using System; + namespace Jellyfin.Api.Models.SyncPlayDtos { /// @@ -10,14 +12,14 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public MovePlaylistItemRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// /// Gets or sets the playlist identifier of the item. /// /// The playlist identifier of the item. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } /// /// Gets or sets the new position. diff --git a/Jellyfin.Api/Models/SyncPlayDtos/NextItemRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/NextItemRequestDto.cs index aa67954e7..f59a93f13 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/NextItemRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/NextItemRequestDto.cs @@ -1,3 +1,5 @@ +using System; + namespace Jellyfin.Api.Models.SyncPlayDtos { /// @@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public NextItemRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// /// Gets or sets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } } } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/PreviousItemRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/PreviousItemRequestDto.cs index b23d4dee0..7fd4a49be 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/PreviousItemRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/PreviousItemRequestDto.cs @@ -1,3 +1,5 @@ +using System; + namespace Jellyfin.Api.Models.SyncPlayDtos { /// @@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public PreviousItemRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// /// Gets or sets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } } } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/ReadyRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/ReadyRequestDto.cs index 0155d5249..d9c193016 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/ReadyRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/ReadyRequestDto.cs @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public ReadyRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// @@ -37,6 +37,6 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// Gets or sets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } } } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/RemoveFromPlaylistRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/RemoveFromPlaylistRequestDto.cs index facb809fc..e9b2b2cb3 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/RemoveFromPlaylistRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/RemoveFromPlaylistRequestDto.cs @@ -13,13 +13,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public RemoveFromPlaylistRequestDto() { - PlaylistItemIds = Array.Empty(); + PlaylistItemIds = Array.Empty(); } /// /// Gets or sets the playlist identifiers ot the items. /// /// The playlist identifiers ot the items. - public IReadOnlyList PlaylistItemIds { get; set; } + public IReadOnlyList PlaylistItemIds { get; set; } } } diff --git a/Jellyfin.Api/Models/SyncPlayDtos/SetPlaylistItemRequestDto.cs b/Jellyfin.Api/Models/SyncPlayDtos/SetPlaylistItemRequestDto.cs index 344085871..b937679fc 100644 --- a/Jellyfin.Api/Models/SyncPlayDtos/SetPlaylistItemRequestDto.cs +++ b/Jellyfin.Api/Models/SyncPlayDtos/SetPlaylistItemRequestDto.cs @@ -1,3 +1,5 @@ +using System; + namespace Jellyfin.Api.Models.SyncPlayDtos { /// @@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos /// public SetPlaylistItemRequestDto() { - PlaylistItemId = string.Empty; + PlaylistItemId = Guid.Empty; } /// /// Gets or sets the playlist identifier of the playing item. /// /// The playlist identifier of the playing item. - public string PlaylistItemId { get; set; } + public Guid PlaylistItemId { get; set; } } } diff --git a/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs b/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs index f5f603c29..c2820604f 100644 --- a/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs +++ b/MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs @@ -329,7 +329,7 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates } // Make sure the client is playing the correct item. - if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId(), StringComparison.OrdinalIgnoreCase)) + if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("Session {SessionId} reported wrong playlist item in group {GroupId}.", session.Id, context.GroupId.ToString()); @@ -403,7 +403,7 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates } // Make sure the client is playing the correct item. - if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId(), StringComparison.OrdinalIgnoreCase)) + if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("Session {SessionId} reported wrong playlist item in group {GroupId}.", session.Id, context.GroupId.ToString()); @@ -572,7 +572,7 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates ResumePlaying = true; // Make sure the client knows the playing item, to avoid duplicate requests. - if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId(), StringComparison.OrdinalIgnoreCase)) + if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("Session {SessionId} provided the wrong playlist item for group {GroupId}.", session.Id, context.GroupId.ToString()); return; @@ -618,7 +618,7 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates ResumePlaying = true; // Make sure the client knows the playing item, to avoid duplicate requests. - if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId(), StringComparison.OrdinalIgnoreCase)) + if (!request.PlaylistItemId.Equals(context.PlayQueue.GetPlayingItemPlaylistId())) { _logger.LogDebug("Session {SessionId} provided the wrong playlist item for group {GroupId}.", session.Id, context.GroupId.ToString()); return; diff --git a/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs b/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs index 13f1b2316..aa263638a 100644 --- a/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs +++ b/MediaBrowser.Controller/SyncPlay/IGroupStateContext.cs @@ -158,14 +158,14 @@ namespace MediaBrowser.Controller.SyncPlay /// /// The new playing item identifier. /// true if the play queue has been changed; false if something went wrong. - bool SetPlayingItem(string playlistItemId); + bool SetPlayingItem(Guid playlistItemId); /// /// Removes items from the play queue. /// /// The items to remove. /// true if playing item got removed; false otherwise. - bool RemoveFromPlayQueue(IReadOnlyList playlistItemIds); + bool RemoveFromPlayQueue(IReadOnlyList playlistItemIds); /// /// Moves an item in the play queue. @@ -173,7 +173,7 @@ namespace MediaBrowser.Controller.SyncPlay /// The playlist identifier of the item to move. /// The new position. /// true if item has been moved; false if something went wrong. - bool MoveItemInPlayQueue(string playlistItemId, int newIndex); + bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex); /// /// Updates the play queue. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs index 2981dbbdd..39e0ec209 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/BufferGroupRequest.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// 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) + public BufferGroupRequest(DateTime when, long positionTicks, bool isPlaying, Guid playlistItemId) { When = when; PositionTicks = positionTicks; @@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.Buffer; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs index efca4ed3e..7ebf67af1 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/MovePlaylistItemGroupRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; @@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// /// The playlist identifier of the item. /// The new position. - public MovePlaylistItemGroupRequest(string playlistItemId, int newIndex) + public MovePlaylistItemGroupRequest(Guid playlistItemId, int newIndex) { PlaylistItemId = playlistItemId; NewIndex = newIndex; @@ -24,7 +25,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playlist identifier of the item. /// /// The playlist identifier of the item. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// /// Gets the new position. diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextItemGroupRequest.cs index ab60265a6..478414137 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/NextItemGroupRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; @@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Initializes a new instance of the class. /// /// The playing item identifier. - public NextItemGroupRequest(string playlistItemId) + public NextItemGroupRequest(Guid playlistItemId) { PlaylistItemId = playlistItemId; } @@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.NextItem; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousItemGroupRequest.cs index 445c5fce6..ad3ea5e55 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/PreviousItemGroupRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; @@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Initializes a new instance of the class. /// /// The playing item identifier. - public PreviousItemGroupRequest(string playlistItemId) + public PreviousItemGroupRequest(Guid playlistItemId) { PlaylistItemId = playlistItemId; } @@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playing item identifier. /// /// The playing item identifier. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.PreviousItem; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs index b09db4ba8..b2efcc97d 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/ReadyGroupRequest.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// 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) + public ReadyGroupRequest(DateTime when, long positionTicks, bool isPlaying, Guid playlistItemId) { When = when; PositionTicks = positionTicks; @@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playlist item identifier of the playing item. /// /// The playlist item identifier. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.Ready; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs index dac1914aa..24009d93c 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/RemoveFromPlaylistGroupRequest.cs @@ -15,16 +15,16 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Initializes a new instance of the class. /// /// The playlist ids of the items to remove. - public RemoveFromPlaylistGroupRequest(IReadOnlyList items) + public RemoveFromPlaylistGroupRequest(IReadOnlyList items) { - PlaylistItemIds = items ?? Array.Empty(); + PlaylistItemIds = items ?? Array.Empty(); } /// /// Gets the playlist identifiers ot the items. /// /// The playlist identifiers ot the items. - public IReadOnlyList PlaylistItemIds { get; } + public IReadOnlyList PlaylistItemIds { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist; diff --git a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs index 58fed3fa0..3edf9b8a4 100644 --- a/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs +++ b/MediaBrowser.Controller/SyncPlay/PlaybackRequests/SetPlaylistItemGroupRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using MediaBrowser.Controller.Session; using MediaBrowser.Model.SyncPlay; @@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Initializes a new instance of the class. /// /// The playlist identifier of the item. - public SetPlaylistItemGroupRequest(string playlistItemId) + public SetPlaylistItemGroupRequest(Guid playlistItemId) { PlaylistItemId = playlistItemId; } @@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests /// Gets the playlist identifier of the playing item. /// /// The playlist identifier of the playing item. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// public override PlaybackRequestType Action { get; } = PlaybackRequestType.SetPlaylistItem; diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs index bfb9d1e4c..fdec29417 100644 --- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs +++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs @@ -66,12 +66,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// The shuffled playlist, or play queue of the group. private List ShuffledPlaylist { get; set; } = new List(); - /// - /// Gets or sets the progressive identifier counter. - /// - /// The progressive identifier. - private int ProgressiveId { get; set; } - /// /// Checks if an item is playing. /// @@ -233,10 +227,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// Gets playlist identifier of the playing item, if any. /// /// The playlist identifier of the playing item. - public string GetPlayingItemPlaylistId() + public Guid GetPlayingItemPlaylistId() { var playingItem = GetPlayingItem(); - return playingItem?.PlaylistItemId; + return playingItem?.PlaylistItemId ?? Guid.Empty; } /// @@ -265,10 +259,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// /// The new playing item identifier. /// true if playing item has been set; false if item is not in the playlist. - public bool SetPlayingItemByPlaylistId(string playlistItemId) + public bool SetPlayingItemByPlaylistId(Guid playlistItemId) { var playlist = GetPlaylistInternal(); - PlayingItemIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase)); + PlayingItemIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId)); LastChange = DateTime.UtcNow; return PlayingItemIndex != NoPlayingItemIndex; @@ -298,7 +292,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// /// The items to remove. /// true if playing item got removed; false otherwise. - public bool RemoveFromPlaylist(IReadOnlyList playlistItemIds) + public bool RemoveFromPlaylist(IReadOnlyList playlistItemIds) { var playingItem = GetPlayingItem(); @@ -341,12 +335,12 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// The item to move. /// The new position. /// true if the item has been moved; false otherwise. - public bool MovePlaylistItem(string playlistItemId, int newIndex) + public bool MovePlaylistItem(Guid playlistItemId, int newIndex) { var playlist = GetPlaylistInternal(); var playingItem = GetPlayingItem(); - var oldIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase)); + var oldIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId)); if (oldIndex < 0) { return false; @@ -367,7 +361,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue /// public void Reset() { - ProgressiveId = 0; SortedPlaylist.Clear(); ShuffledPlaylist.Clear(); PlayingItemIndex = NoPlayingItemIndex; @@ -529,15 +522,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue } } - /// - /// Gets the next available identifier. - /// - /// The next available identifier. - private int GetNextProgressiveId() - { - return ProgressiveId++; - } - /// /// Creates a list from the array of items. Each item is given an unique playlist identifier. /// @@ -547,7 +531,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue var list = new List(); foreach (var item in items) { - var queueItem = new QueueItem(item, "syncPlayItem" + GetNextProgressiveId()); + var queueItem = new QueueItem(item); list.Add(queueItem); } diff --git a/MediaBrowser.Model/SyncPlay/QueueItem.cs b/MediaBrowser.Model/SyncPlay/QueueItem.cs index 9c4d3a4ce..a6dcc109e 100644 --- a/MediaBrowser.Model/SyncPlay/QueueItem.cs +++ b/MediaBrowser.Model/SyncPlay/QueueItem.cs @@ -11,11 +11,9 @@ namespace MediaBrowser.Model.SyncPlay /// Initializes a new instance of the class. /// /// The item identifier. - /// The playlist identifier of the item. - public QueueItem(Guid itemId, string playlistItemId) + public QueueItem(Guid itemId) { ItemId = itemId; - PlaylistItemId = playlistItemId; } /// @@ -28,6 +26,6 @@ namespace MediaBrowser.Model.SyncPlay /// Gets the playlist identifier of the item. /// /// The playlist identifier of the item. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } = Guid.NewGuid(); } } diff --git a/MediaBrowser.Model/SyncPlay/SendCommand.cs b/MediaBrowser.Model/SyncPlay/SendCommand.cs index ab4c64130..73cb50876 100644 --- a/MediaBrowser.Model/SyncPlay/SendCommand.cs +++ b/MediaBrowser.Model/SyncPlay/SendCommand.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Model.SyncPlay /// The command. /// The position ticks, for commands that require it. /// The UTC time when this command has been emitted. - public SendCommand(Guid groupId, string playlistItemId, DateTime when, SendCommandType command, long? positionTicks, DateTime emittedAt) + public SendCommand(Guid groupId, Guid playlistItemId, DateTime when, SendCommandType command, long? positionTicks, DateTime emittedAt) { GroupId = groupId; PlaylistItemId = playlistItemId; @@ -36,7 +36,7 @@ namespace MediaBrowser.Model.SyncPlay /// Gets the playlist identifier of the playing item. /// /// The playlist identifier of the playing item. - public string PlaylistItemId { get; } + public Guid PlaylistItemId { get; } /// /// Gets or sets the UTC time when to execute the command.