diff --git a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
index 8bc21a6a8..821a6314b 100644
--- a/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
+++ b/MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
@@ -269,18 +269,8 @@ namespace MediaBrowser.Controller.SyncPlay
/// The new playing item identifier.
public void SetPlayingItemById(Guid itemId)
{
- PlayingItemIndex = NoPlayingItemIndex;
-
var playlist = GetPlaylistInternal();
- foreach (var item in playlist)
- {
- if (item.ItemId.Equals(itemId))
- {
- PlayingItemIndex = playlist.IndexOf(item);
- break;
- }
- }
-
+ PlayingItemIndex = playlist.FindIndex(item => item.ItemId.Equals(itemId));
LastChange = DateTime.UtcNow;
}
@@ -291,19 +281,10 @@ namespace MediaBrowser.Controller.SyncPlay
/// true if playing item has been set; false if item is not in the playlist.
public bool SetPlayingItemByPlaylistId(string playlistItemId)
{
- PlayingItemIndex = NoPlayingItemIndex;
-
var playlist = GetPlaylistInternal();
- foreach (var item in playlist)
- {
- if (item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase))
- {
- PlayingItemIndex = playlist.IndexOf(item);
- break;
- }
- }
-
+ PlayingItemIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase));
LastChange = DateTime.UtcNow;
+
return PlayingItemIndex != NoPlayingItemIndex;
}
@@ -380,16 +361,7 @@ namespace MediaBrowser.Controller.SyncPlay
var playlist = GetPlaylistInternal();
var playingItem = GetPlayingItem();
- var oldIndex = -1;
- foreach (var item in playlist)
- {
- if (item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase))
- {
- oldIndex = playlist.IndexOf(item);
- break;
- }
- }
-
+ var oldIndex = playlist.FindIndex(item => item.PlaylistItemId.Equals(playlistItemId, StringComparison.OrdinalIgnoreCase));
if (oldIndex < 0)
{
return false;