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

View File

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

View File

@ -1,3 +1,5 @@
using System;
namespace Jellyfin.Api.Models.SyncPlayDtos namespace Jellyfin.Api.Models.SyncPlayDtos
{ {
/// <summary> /// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary> /// </summary>
public NextItemRequestDto() public NextItemRequestDto()
{ {
PlaylistItemId = string.Empty; PlaylistItemId = Guid.Empty;
} }
/// <summary> /// <summary>
/// Gets or sets the playing item identifier. /// Gets or sets the playing item identifier.
/// </summary> /// </summary>
/// <value>The playing item identifier.</value> /// <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 namespace Jellyfin.Api.Models.SyncPlayDtos
{ {
/// <summary> /// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary> /// </summary>
public PreviousItemRequestDto() public PreviousItemRequestDto()
{ {
PlaylistItemId = string.Empty; PlaylistItemId = Guid.Empty;
} }
/// <summary> /// <summary>
/// Gets or sets the playing item identifier. /// Gets or sets the playing item identifier.
/// </summary> /// </summary>
/// <value>The playing item identifier.</value> /// <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> /// </summary>
public ReadyRequestDto() public ReadyRequestDto()
{ {
PlaylistItemId = string.Empty; PlaylistItemId = Guid.Empty;
} }
/// <summary> /// <summary>
@ -37,6 +37,6 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// Gets or sets the playlist item identifier of the playing item. /// Gets or sets the playlist item identifier of the playing item.
/// </summary> /// </summary>
/// <value>The playlist item identifier.</value> /// <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> /// </summary>
public RemoveFromPlaylistRequestDto() public RemoveFromPlaylistRequestDto()
{ {
PlaylistItemIds = Array.Empty<string>(); PlaylistItemIds = Array.Empty<Guid>();
} }
/// <summary> /// <summary>
/// Gets or sets the playlist identifiers ot the items. /// Gets or sets the playlist identifiers ot the items.
/// </summary> /// </summary>
/// <value>The playlist identifiers ot the items.</value> /// <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 namespace Jellyfin.Api.Models.SyncPlayDtos
{ {
/// <summary> /// <summary>
@ -10,13 +12,13 @@ namespace Jellyfin.Api.Models.SyncPlayDtos
/// </summary> /// </summary>
public SetPlaylistItemRequestDto() public SetPlaylistItemRequestDto()
{ {
PlaylistItemId = string.Empty; PlaylistItemId = Guid.Empty;
} }
/// <summary> /// <summary>
/// Gets or sets the playlist identifier of the playing item. /// Gets or sets the playlist identifier of the playing item.
/// </summary> /// </summary>
/// <value>The playlist identifier of the playing item.</value> /// <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. // 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()); _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. // 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()); _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; ResumePlaying = true;
// Make sure the client knows the playing item, to avoid duplicate requests. // 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()); _logger.LogDebug("Session {SessionId} provided the wrong playlist item for group {GroupId}.", session.Id, context.GroupId.ToString());
return; return;
@ -618,7 +618,7 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates
ResumePlaying = true; ResumePlaying = true;
// Make sure the client knows the playing item, to avoid duplicate requests. // 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()); _logger.LogDebug("Session {SessionId} provided the wrong playlist item for group {GroupId}.", session.Id, context.GroupId.ToString());
return; return;

View File

@ -158,14 +158,14 @@ namespace MediaBrowser.Controller.SyncPlay
/// </summary> /// </summary>
/// <param name="playlistItemId">The new playing item identifier.</param> /// <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> /// <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> /// <summary>
/// Removes items from the play queue. /// Removes items from the play queue.
/// </summary> /// </summary>
/// <param name="playlistItemIds">The items to remove.</param> /// <param name="playlistItemIds">The items to remove.</param>
/// <returns><c>true</c> if playing item got removed; <c>false</c> otherwise.</returns> /// <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> /// <summary>
/// Moves an item in the play queue. /// 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="playlistItemId">The playlist identifier of the item to move.</param>
/// <param name="newIndex">The new position.</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> /// <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> /// <summary>
/// Updates the play queue. /// Updates the play queue.

View File

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

View File

@ -1,3 +1,4 @@
using System;
using System.Threading; using System.Threading;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.SyncPlay; using MediaBrowser.Model.SyncPlay;
@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// </summary> /// </summary>
/// <param name="playlistItemId">The playlist identifier of the item.</param> /// <param name="playlistItemId">The playlist identifier of the item.</param>
/// <param name="newIndex">The new position.</param> /// <param name="newIndex">The new position.</param>
public MovePlaylistItemGroupRequest(string playlistItemId, int newIndex) public MovePlaylistItemGroupRequest(Guid playlistItemId, int newIndex)
{ {
PlaylistItemId = playlistItemId; PlaylistItemId = playlistItemId;
NewIndex = newIndex; NewIndex = newIndex;
@ -24,7 +25,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playlist identifier of the item. /// Gets the playlist identifier of the item.
/// </summary> /// </summary>
/// <value>The playlist identifier of the item.</value> /// <value>The playlist identifier of the item.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <summary> /// <summary>
/// Gets the new position. /// Gets the new position.

View File

@ -1,3 +1,4 @@
using System;
using System.Threading; using System.Threading;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.SyncPlay; using MediaBrowser.Model.SyncPlay;
@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Initializes a new instance of the <see cref="NextItemGroupRequest"/> class. /// Initializes a new instance of the <see cref="NextItemGroupRequest"/> class.
/// </summary> /// </summary>
/// <param name="playlistItemId">The playing item identifier.</param> /// <param name="playlistItemId">The playing item identifier.</param>
public NextItemGroupRequest(string playlistItemId) public NextItemGroupRequest(Guid playlistItemId)
{ {
PlaylistItemId = playlistItemId; PlaylistItemId = playlistItemId;
} }
@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playing item identifier. /// Gets the playing item identifier.
/// </summary> /// </summary>
/// <value>The playing item identifier.</value> /// <value>The playing item identifier.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <inheritdoc /> /// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.NextItem; public override PlaybackRequestType Action { get; } = PlaybackRequestType.NextItem;

View File

@ -1,3 +1,4 @@
using System;
using System.Threading; using System.Threading;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.SyncPlay; using MediaBrowser.Model.SyncPlay;
@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Initializes a new instance of the <see cref="PreviousItemGroupRequest"/> class. /// Initializes a new instance of the <see cref="PreviousItemGroupRequest"/> class.
/// </summary> /// </summary>
/// <param name="playlistItemId">The playing item identifier.</param> /// <param name="playlistItemId">The playing item identifier.</param>
public PreviousItemGroupRequest(string playlistItemId) public PreviousItemGroupRequest(Guid playlistItemId)
{ {
PlaylistItemId = playlistItemId; PlaylistItemId = playlistItemId;
} }
@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playing item identifier. /// Gets the playing item identifier.
/// </summary> /// </summary>
/// <value>The playing item identifier.</value> /// <value>The playing item identifier.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <inheritdoc /> /// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.PreviousItem; 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="positionTicks">The position ticks.</param>
/// <param name="isPlaying">Whether the client playback is unpaused.</param> /// <param name="isPlaying">Whether the client playback is unpaused.</param>
/// <param name="playlistItemId">The playlist item identifier of the playing item.</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; When = when;
PositionTicks = positionTicks; PositionTicks = positionTicks;
@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playlist item identifier of the playing item. /// Gets the playlist item identifier of the playing item.
/// </summary> /// </summary>
/// <value>The playlist item identifier.</value> /// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <inheritdoc /> /// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.Ready; 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. /// Initializes a new instance of the <see cref="RemoveFromPlaylistGroupRequest"/> class.
/// </summary> /// </summary>
/// <param name="items">The playlist ids of the items to remove.</param> /// <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> /// <summary>
/// Gets the playlist identifiers ot the items. /// Gets the playlist identifiers ot the items.
/// </summary> /// </summary>
/// <value>The playlist identifiers ot the items.</value> /// <value>The playlist identifiers ot the items.</value>
public IReadOnlyList<string> PlaylistItemIds { get; } public IReadOnlyList<Guid> PlaylistItemIds { get; }
/// <inheritdoc /> /// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist; public override PlaybackRequestType Action { get; } = PlaybackRequestType.RemoveFromPlaylist;

View File

@ -1,3 +1,4 @@
using System;
using System.Threading; using System.Threading;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.SyncPlay; using MediaBrowser.Model.SyncPlay;
@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Initializes a new instance of the <see cref="SetPlaylistItemGroupRequest"/> class. /// Initializes a new instance of the <see cref="SetPlaylistItemGroupRequest"/> class.
/// </summary> /// </summary>
/// <param name="playlistItemId">The playlist identifier of the item.</param> /// <param name="playlistItemId">The playlist identifier of the item.</param>
public SetPlaylistItemGroupRequest(string playlistItemId) public SetPlaylistItemGroupRequest(Guid playlistItemId)
{ {
PlaylistItemId = playlistItemId; PlaylistItemId = playlistItemId;
} }
@ -22,7 +23,7 @@ namespace MediaBrowser.Controller.SyncPlay.PlaybackRequests
/// Gets the playlist identifier of the playing item. /// Gets the playlist identifier of the playing item.
/// </summary> /// </summary>
/// <value>The playlist identifier of the playing item.</value> /// <value>The playlist identifier of the playing item.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <inheritdoc /> /// <inheritdoc />
public override PlaybackRequestType Action { get; } = PlaybackRequestType.SetPlaylistItem; 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> /// <value>The shuffled playlist, or play queue of the group.</value>
private List<QueueItem> ShuffledPlaylist { get; set; } = new List<QueueItem>(); 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> /// <summary>
/// Checks if an item is playing. /// Checks if an item is playing.
/// </summary> /// </summary>
@ -233,10 +227,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// Gets playlist identifier of the playing item, if any. /// Gets playlist identifier of the playing item, if any.
/// </summary> /// </summary>
/// <returns>The playlist identifier of the playing item.</returns> /// <returns>The playlist identifier of the playing item.</returns>
public string GetPlayingItemPlaylistId() public Guid GetPlayingItemPlaylistId()
{ {
var playingItem = GetPlayingItem(); var playingItem = GetPlayingItem();
return playingItem?.PlaylistItemId; return playingItem?.PlaylistItemId ?? Guid.Empty;
} }
/// <summary> /// <summary>
@ -265,10 +259,10 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// </summary> /// </summary>
/// <param name="playlistItemId">The new playing item identifier.</param> /// <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> /// <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(); var playlist = GetPlaylistInternal();
PlayingItemIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase)); PlayingItemIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId));
LastChange = DateTime.UtcNow; LastChange = DateTime.UtcNow;
return PlayingItemIndex != NoPlayingItemIndex; return PlayingItemIndex != NoPlayingItemIndex;
@ -298,7 +292,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// </summary> /// </summary>
/// <param name="playlistItemIds">The items to remove.</param> /// <param name="playlistItemIds">The items to remove.</param>
/// <returns><c>true</c> if playing item got removed; <c>false</c> otherwise.</returns> /// <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(); var playingItem = GetPlayingItem();
@ -341,12 +335,12 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// <param name="playlistItemId">The item to move.</param> /// <param name="playlistItemId">The item to move.</param>
/// <param name="newIndex">The new position.</param> /// <param name="newIndex">The new position.</param>
/// <returns><c>true</c> if the item has been moved; <c>false</c> otherwise.</returns> /// <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 playlist = GetPlaylistInternal();
var playingItem = GetPlayingItem(); 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) if (oldIndex < 0)
{ {
return false; return false;
@ -367,7 +361,6 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {
ProgressiveId = 0;
SortedPlaylist.Clear(); SortedPlaylist.Clear();
ShuffledPlaylist.Clear(); ShuffledPlaylist.Clear();
PlayingItemIndex = NoPlayingItemIndex; 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> /// <summary>
/// Creates a list from the array of items. Each item is given an unique playlist identifier. /// Creates a list from the array of items. Each item is given an unique playlist identifier.
/// </summary> /// </summary>
@ -547,7 +531,7 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
var list = new List<QueueItem>(); var list = new List<QueueItem>();
foreach (var item in items) foreach (var item in items)
{ {
var queueItem = new QueueItem(item, "syncPlayItem" + GetNextProgressiveId()); var queueItem = new QueueItem(item);
list.Add(queueItem); list.Add(queueItem);
} }

View File

@ -11,11 +11,9 @@ namespace MediaBrowser.Model.SyncPlay
/// Initializes a new instance of the <see cref="QueueItem"/> class. /// Initializes a new instance of the <see cref="QueueItem"/> class.
/// </summary> /// </summary>
/// <param name="itemId">The item identifier.</param> /// <param name="itemId">The item identifier.</param>
/// <param name="playlistItemId">The playlist identifier of the item.</param> public QueueItem(Guid itemId)
public QueueItem(Guid itemId, string playlistItemId)
{ {
ItemId = itemId; ItemId = itemId;
PlaylistItemId = playlistItemId;
} }
/// <summary> /// <summary>
@ -28,6 +26,6 @@ namespace MediaBrowser.Model.SyncPlay
/// Gets the playlist identifier of the item. /// Gets the playlist identifier of the item.
/// </summary> /// </summary>
/// <value>The playlist identifier of the item.</value> /// <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="command">The command.</param>
/// <param name="positionTicks">The position ticks, for commands that require it.</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> /// <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; GroupId = groupId;
PlaylistItemId = playlistItemId; PlaylistItemId = playlistItemId;
@ -36,7 +36,7 @@ namespace MediaBrowser.Model.SyncPlay
/// Gets the playlist identifier of the playing item. /// Gets the playlist identifier of the playing item.
/// </summary> /// </summary>
/// <value>The playlist identifier of the playing item.</value> /// <value>The playlist identifier of the playing item.</value>
public string PlaylistItemId { get; } public Guid PlaylistItemId { get; }
/// <summary> /// <summary>
/// Gets or sets the UTC time when to execute the command. /// Gets or sets the UTC time when to execute the command.