Change type of PlaylistItemId to Guid

This commit is contained in:
Ionut Andrei Oanca 2020-12-04 20:15:16 +01:00
parent b7eb4da04e
commit cbf70e7a03
20 changed files with 63 additions and 69 deletions

View File

@ -505,7 +505,7 @@ namespace Emby.Server.Implementations.SyncPlay
}
/// <inheritdoc />
public bool SetPlayingItem(string playlistItemId)
public bool SetPlayingItem(Guid playlistItemId)
{
var itemFound = PlayQueue.SetPlayingItemByPlaylistId(playlistItemId);
@ -525,7 +525,7 @@ namespace Emby.Server.Implementations.SyncPlay
}
/// <inheritdoc />
public bool RemoveFromPlayQueue(IReadOnlyList<string> playlistItemIds)
public bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds)
{
var playingItemRemoved = PlayQueue.RemoveFromPlaylist(playlistItemIds);
if (playingItemRemoved)
@ -548,7 +548,7 @@ namespace Emby.Server.Implementations.SyncPlay
}
/// <inheritdoc />
public bool MoveItemInPlayQueue(string playlistItemId, int newIndex)
public bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex)
{
return PlayQueue.MovePlaylistItem(playlistItemId, newIndex);
}

View File

@ -12,7 +12,7 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public BufferRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
@ -37,6 +37,6 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// Gets or sets the playlist item identifier of the playing item.
/// </summary>
/// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
}
}

View File

@ -1,3 +1,5 @@
using System;
namespace Jellyfin.Api.Models.SyncPlayDtos
{
/// <summary>
@ -10,14 +12,14 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public MovePlaylistItemRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
/// Gets or sets the playlist identifier of the item.
/// </summary>
/// <value>The playlist identifier of the item.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
/// <summary>
/// Gets or sets the new position.

View File

@ -1,3 +1,5 @@
using System;
namespace Jellyfin.Api.Models.SyncPlayDtos
{
/// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public NextItemRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
/// Gets or sets the playing item identifier.
/// </summary>
/// <value>The playing item identifier.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
}
}

View File

@ -1,3 +1,5 @@
using System;
namespace Jellyfin.Api.Models.SyncPlayDtos
{
/// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public PreviousItemRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
/// Gets or sets the playing item identifier.
/// </summary>
/// <value>The playing item identifier.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
}
}

View File

@ -12,7 +12,7 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public ReadyRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
@ -37,6 +37,6 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// Gets or sets the playlist item identifier of the playing item.
/// </summary>
/// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
}
}

View File

@ -13,13 +13,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public RemoveFromPlaylistRequestDto()
{
PlaylistItemIds = Array.Empty<string>();
PlaylistItemIds = Array.Empty<Guid>();
}
/// <summary>
/// Gets or sets the playlist identifiers ot the items.
/// </summary>
/// <value>The playlist identifiers ot the items.</value>
public IReadOnlyList<string> PlaylistItemIds { get; set; }
public IReadOnlyList<Guid> PlaylistItemIds { get; set; }
}
}

View File

@ -1,3 +1,5 @@
using System;
namespace Jellyfin.Api.Models.SyncPlayDtos
{
/// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary>
public SetPlaylistItemRequestDto()
{
PlaylistItemId = string.Empty;
PlaylistItemId = Guid.Empty;
}
/// <summary>
/// Gets or sets the playlist identifier of the playing item.
/// </summary>
/// <value>The playlist identifier of the playing item.</value>
public string PlaylistItemId { get; set; }
public Guid PlaylistItemId { get; set; }
}
}

View File

@ -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;

View File

@ -158,14 +158,14 @@ namespace MediaBrowser.Controller.SyncPlay
/// </summary>
/// <param name="playlistItemId">The new playing item identifier.</param>
/// <returns><c>true</c> if the play queue has been changed; <c>false</c> if something went wrong.</returns>
bool SetPlayingItem(string playlistItemId);
bool SetPlayingItem(Guid playlistItemId);
/// <summary>
/// Removes items from the play queue.
/// </summary>
/// <param name="playlistItemIds">The items to remove.</param>
/// <returns><c>true</c> if playing item got removed; <c>false</c> otherwise.</returns>
bool RemoveFromPlayQueue(IReadOnlyList<string> playlistItemIds);
bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds);
/// <summary>
/// Moves an item in the play queue.
@ -173,7 +173,7 @@ namespace MediaBrowser.Controller.SyncPlay
/// <param name="playlistItemId">The playlist identifier of the item to move.</param>
/// <param name="newIndex">The new position.</param>
/// <returns><c>true</c> if item has been moved; <c>false</c> if something went wrong.</returns>
bool MoveItemInPlayQueue(string playlistItemId, int newIndex);
bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex);
/// <summary>
/// Updates the play queue.

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// <param name="positionTicks">The position ticks.</param>
/// <param name="isPlaying">Whether the client playback is unpaused.</param>
/// <param name="playlistItemId">The playlist item identifier of the playing item.</param>
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.
/// </summary>
/// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.Buffer;

View File

@ -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
/// </summary>
/// <param name="playlistItemId">The playlist identifier of the item.</param>
/// <param name="newIndex">The new position.</param>
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.
/// </summary>
/// <value>The playlist identifier of the item.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <summary>
/// Gets the new position.

View File

@ -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 <see cref="NextItemGroupRequest"/> class.
/// </summary>
/// <param name="playlistItemId">The playing item identifier.</param>
public NextItemGroupRequest(string playlistItemId)
public NextItemGroupRequest(Guid playlistItemId)
{
PlaylistItemId = playlistItemId;
}
@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playing item identifier.
/// </summary>
/// <value>The playing item identifier.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.NextItem;

View File

@ -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 <see cref="PreviousItemGroupRequest"/> class.
/// </summary>
/// <param name="playlistItemId">The playing item identifier.</param>
public PreviousItemGroupRequest(string playlistItemId)
public PreviousItemGroupRequest(Guid playlistItemId)
{
PlaylistItemId = playlistItemId;
}
@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playing item identifier.
/// </summary>
/// <value>The playing item identifier.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.PreviousItem;

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// <param name="positionTicks">The position ticks.</param>
/// <param name="isPlaying">Whether the client playback is unpaused.</param>
/// <param name="playlistItemId">The playlist item identifier of the playing item.</param>
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.
/// </summary>
/// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.Ready;

View File

@ -15,16 +15,16 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Initializes a new instance of the <see cref="RemoveFromPlaylistGroupRequest"/> class.
/// </summary>
/// <param name="items">The playlist ids of the items to remove.</param>
public RemoveFromPlaylistGroupRequest(IReadOnlyList<string> items)
public RemoveFromPlaylistGroupRequest(IReadOnlyList<Guid> items)
{
PlaylistItemIds = items ?? Array.Empty<string>();
PlaylistItemIds = items ?? Array.Empty<Guid>();
}
/// <summary>
/// Gets the playlist identifiers ot the items.
/// </summary>
/// <value>The playlist identifiers ot the items.</value>
public IReadOnlyList<string> PlaylistItemIds { get; }
public IReadOnlyList<Guid> PlaylistItemIds { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist;

View File

@ -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 <see cref="SetPlaylistItemGroupRequest"/> class.
/// </summary>
/// <param name="playlistItemId">The playlist identifier of the item.</param>
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.
/// </summary>
/// <value>The playlist identifier of the playing item.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.SetPlaylistItem;

View File

@ -66,12 +66,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// <value>The shuffled playlist, or play queue of the group.</value>
private List<QueueItem> ShuffledPlaylist { get; set; } = new List<QueueItem>();
/// <summary>
/// Gets or sets the progressive identifier counter.
/// </summary>
/// <value>The progressive identifier.</value>
private int ProgressiveId { get; set; }
/// <summary>
/// Checks if an item is playing.
/// </summary>
@ -233,10 +227,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// Gets playlist identifier of the playing item, if any.
/// </summary>
/// <returns>The playlist identifier of the playing item.</returns>
public string GetPlayingItemPlaylistId()
public Guid GetPlayingItemPlaylistId()
{
var playingItem = GetPlayingItem();
return playingItem?.PlaylistItemId;
return playingItem?.PlaylistItemId ?? Guid.Empty;
}
/// <summary>
@ -265,10 +259,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// </summary>
/// <param name="playlistItemId">The new playing item identifier.</param>
/// <returns><c>true</c> if playing item has been set; <c>false</c> if item is not in the playlist.</returns>
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
/// </summary>
/// <param name="playlistItemIds">The items to remove.</param>
/// <returns><c>true</c> if playing item got removed; <c>false</c> otherwise.</returns>
public bool RemoveFromPlaylist(IReadOnlyList<string> playlistItemIds)
public bool RemoveFromPlaylist(IReadOnlyList<Guid> playlistItemIds)
{
var playingItem = GetPlayingItem();
@ -341,12 +335,12 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// <param name="playlistItemId">The item to move.</param>
/// <param name="newIndex">The new position.</param>
/// <returns><c>true</c> if the item has been moved; <c>false</c> otherwise.</returns>
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
/// </summary>
public void Reset()
{
ProgressiveId = 0;
SortedPlaylist.Clear();
ShuffledPlaylist.Clear();
PlayingItemIndex = NoPlayingItemIndex;
@ -529,15 +522,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
}
}
/// <summary>
/// Gets the next available identifier.
/// </summary>
/// <returns>The next available identifier.</returns>
private int GetNextProgressiveId()
{
return ProgressiveId++;
}
/// <summary>
/// Creates a list from the array of items. Each item is given an unique playlist identifier.
/// </summary>
@ -547,7 +531,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
var list = new List<QueueItem>();
foreach (var item in items)
{
var queueItem = new QueueItem(item, "syncPlayItem" + GetNextProgressiveId());
var queueItem = new QueueItem(item);
list.Add(queueItem);
}

View File

@ -11,11 +11,9 @@ namespace MediaBrowser.Model.SyncPlay
/// Initializes a new instance of the <see cref="QueueItem"/> class.
/// </summary>
/// <param name="itemId">The item identifier.</param>
/// <param name="playlistItemId">The playlist identifier of the item.</param>
public QueueItem(Guid itemId, string playlistItemId)
public QueueItem(Guid itemId)
{
ItemId = itemId;
PlaylistItemId = playlistItemId;
}
/// <summary>
@ -28,6 +26,6 @@ namespace MediaBrowser.Model.SyncPlay
/// Gets the playlist identifier of the item.
/// </summary>
/// <value>The playlist identifier of the item.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; } = Guid.NewGuid();
}
}

View File

@ -16,7 +16,7 @@ namespace MediaBrowser.Model.SyncPlay
/// <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, 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.
/// </summary>
/// <value>The playlist identifier of the playing item.</value>
public string PlaylistItemId { get; }
public Guid PlaylistItemId { get; }
/// <summary>
/// Gets or sets the UTC time when to execute the command.